1 /* 2 * syscall1.c 3 * 4 * N thread getuid timing test (default 1) 5 */ 6 7 #include "blib.h" 8 9 int 10 main(int ac, char **av) 11 { 12 long long count = 0; 13 long long max; 14 char c; 15 int n; 16 int i; 17 int j; 18 int status; 19 20 printf("timing standard getuid() syscall, single thread\n"); 21 printf("if using powerd, run several times\n"); 22 23 start_timing(); 24 while (stop_timing(0, NULL) == 0) { 25 for (j = 0; j < 100; ++j) 26 getuid(); 27 count += 100; 28 } 29 max = count; 30 31 if (ac > 1) 32 n = strtol(av[1], NULL, 0); 33 else 34 n = 1; 35 36 start_timing(); 37 for (i = 0; i < n; ++i) { 38 if (fork() == 0) { 39 for (count = 0; count < max; count += 100) { 40 for (j = 0; j < 100; ++j) 41 getuid(); 42 } 43 _exit(0); 44 } 45 } 46 while (wait3(&status, 0, NULL) >= 0 || errno == EINTR) 47 ; 48 stop_timing(count * n, "getuid()"); 49 50 return(0); 51 } 52 53