1*23f24377SWarner Losh #include <stdio.h>
2*23f24377SWarner Losh #include <string.h>
3*23f24377SWarner Losh #include <stdlib.h>
4*23f24377SWarner Losh #include <sys/types.h>
5*23f24377SWarner Losh #include <sys/times.h>
6*23f24377SWarner Losh #include <time.h>
7*23f24377SWarner Losh
main(int argc,char * argv[])8*23f24377SWarner Losh int main(int argc, char *argv[])
9*23f24377SWarner Losh {
10*23f24377SWarner Losh struct tms before, after;
11*23f24377SWarner Losh char cmd[10000];
12*23f24377SWarner Losh int i;
13*23f24377SWarner Losh double fudge = 100.0; /* should be CLOCKS_PER_SEC but that gives nonsense */
14*23f24377SWarner Losh
15*23f24377SWarner Losh times(&before);
16*23f24377SWarner Losh
17*23f24377SWarner Losh /* ... place code to be timed here ... */
18*23f24377SWarner Losh cmd[0] = 0;
19*23f24377SWarner Losh for (i = 1; i < argc; i++)
20*23f24377SWarner Losh sprintf(cmd+strlen(cmd), "%s ", argv[i]);
21*23f24377SWarner Losh sprintf(cmd+strlen(cmd), "\n");
22*23f24377SWarner Losh /* printf("cmd = [%s]\n", cmd); */
23*23f24377SWarner Losh system(cmd);
24*23f24377SWarner Losh
25*23f24377SWarner Losh times(&after);
26*23f24377SWarner Losh
27*23f24377SWarner Losh fprintf(stderr, "user %6.3f\n", (after.tms_cutime - before.tms_cutime)/fudge);
28*23f24377SWarner Losh fprintf(stderr, "sys %6.3f\n", (after.tms_cstime - before.tms_cstime)/fudge);
29*23f24377SWarner Losh
30*23f24377SWarner Losh return 0;
31*23f24377SWarner Losh }
32