home *** CD-ROM | disk | FTP | other *** search
-
- 1 /* benchfn - benchmark for function calls
- 2 * Thomas Plum, Plum Hall Inc, 609-927-3770
- 3 * Let T be the execution time in milliseconds
- 4 * Then average time per operator = T/major usec
- 5 * (Because the inner loop has exactly 1000 operations)
- 6 */
- 7 #include <stdio.h>
- 8 int dummy = 0;
- 9
- 10 /* f3 - lowest level function
- 11 * Put this in separate source file if compiler detects and optimizes
- 12 * useless code
- 13 */
- 14 f3() { }
- 15
- 16 f2() { f3();f3();f3();f3();f3();f3();f3();f3();f3();f3();} /* 10 */
- 17 f1() { f2();f2();f2();f2();f2();f2();f2();f2();f2();f2();} /* 10 */
- 18 f0() { f1();f1();f1();f1();f1();f1();f1();f1();f1();} /* 9 */
- 19
- 20 main(ac, av)
- 21 int ac;
- 22 char *av[];
- 23 {
- 24 long d, major, atol();
- 25
- 26 major = atol(av[1]);
- 27 printf("executing %ld iterations\n", major);
- 28 for (d = 1; d <= major; ++d)
- 29 f0(); /* executes 1000 calls */
- 30 printf("dummy=%d\n", dummy);
- 31 }