1 /*
2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6 #include <stdio.h>
7 #include <sys/stat.h>
8
9 #include <OS.h>
10
11
12 static void
time_lstat(const char * path)13 time_lstat(const char* path)
14 {
15 printf("%-60s ...", path);
16 fflush(stdout);
17 bigtime_t startTime = system_time();
18
19 static const int32 iterations = 10000;
20 for (int32 i = 0; i < iterations; i++) {
21 struct stat st;
22 lstat(path, &st);
23 }
24
25 bigtime_t totalTime = system_time() - startTime;
26 printf(" %5.3f us/call\n", (double)totalTime / iterations);
27 }
28
29
30 int
main()31 main()
32 {
33 const char* const paths[] = {
34 "/",
35 "/boot",
36 "/boot/develop",
37 "/boot/develop/headers",
38 "/boot/develop/headers/posix",
39 "/boot/develop/headers/posix/sys",
40 "/boot/develop/headers/posix/sys/stat.h",
41 NULL
42 };
43
44 for (int32 i = 0; paths[i] != NULL; i++)
45 time_lstat(paths[i]);
46
47 return 0;
48 }
49