BENCHMUL.C 868 B

123456789101112131415161718192021222324252627282930
  1. /* benchmul - benchmark for int multiply
  2. * Thomas Plum, Plum Hall Inc, 609-927-3770
  3. * If machine traps overflow, use an unsigned type
  4. * Let T be the execution time in milliseconds
  5. * Then average time per operator = T/major usec
  6. * (Because the inner loop has exactly 1000 operations)
  7. */
  8. #define STOR_CL auto
  9. #define TYPE int
  10. #include <stdio.h>
  11. main(int ac, char *av[])
  12. { STOR_CL TYPE a, b, c;
  13. long d, major;
  14. printf ("enter number of iterations\n");
  15. scanf ("%ld", &major);
  16. printf("executing %ld iterations\n", major);
  17. scanf ("%d", &a);
  18. scanf ("%d", &b);
  19. for (d = 1; d <= major; ++d)
  20. {
  21. /* inner loop executes 1000 selected operations */
  22. for (c = 1; c <= 40; ++c)
  23. {
  24. a = 3 *a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a*a*a*a*a*a*a*a * a; /* 25 * */
  25. }
  26. }
  27. printf("a=%d\n", a);
  28. }
  29.