BENCHFN.C 749 B

1234567891011121314151617181920212223
  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. f3() { ;}
  9. f2() { f3();f3();f3();f3();f3();f3();f3();f3();f3();f3();} /* 10 */
  10. f1() { f2();f2();f2();f2();f2();f2();f2();f2();f2();f2();} /* 10 */
  11. f0() { f1();f1();f1();f1();f1();f1();f1();f1();f1();} /* 9 */
  12. main(int ac, char *av[])
  13. { long d, major;
  14. printf ("enter number of iterations ");
  15. scanf ("%ld", &major);
  16. printf("executing %ld iterations\n", major);
  17. for (d = 1; d <= major; ++d)
  18. f0(); /* executes 1000 calls */
  19. printf ("finished\n");
  20. }