2 * from ftp://ftp.netbsd.org/pub/NetBSD/misc/gmcgarry/bench/execbench.tar.gz
4 #define errx(x,y...) { fprintf(stderr, y); fprintf(stderr, "\n"); exit(x); }
12 main(int argc
, char *argv
[])
14 struct timeval before
, after
;
15 unsigned long time
, elapsed
;
16 char timestr
[12], iterstr
[12];
17 char *timeptr
, *countptr
;
21 errx(1, "Usage: %s iterations", argv
[0]);
25 gettimeofday(&before
, NULL
);
26 time
= 1000000 * before
.tv_sec
+ before
.tv_usec
;
27 sprintf(timestr
,"%lu", time
);
38 sprintf(iterstr
, "%d", iter
);
39 execl(argv
[0], argv
[0], "0", iterstr
, timeptr
, countptr
, NULL
);
40 errx(1, "execl failed");
43 gettimeofday(&after
, NULL
);
44 sscanf(argv
[3],"%lu", &time
);
45 count
= atoi(argv
[4]);
46 elapsed
= 1000000 * after
.tv_sec
+ after
.tv_usec
;
49 printf("time: %lu microseconds\n", elapsed
/ count
);