BENCHLNG.C 1013 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* benchlng - benchmark for long integers
  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 long
  10. #include <stdio.h>
  11. main(int ac, char *av[])
  12. { TYPE a, b, c;
  13. long d, major;
  14. scanf ("%ld", &major);
  15. printf("executing %ld iterations\n", major);
  16. scanf ("%ld", &a);
  17. scanf ("%ld", &b);
  18. for (d = 1; d <= major; ++d)
  19. {
  20. /* inner loop executes 1000 selected operations */
  21. for (c = 1; c <= 40; ++c)
  22. {
  23. a = a + b + c;
  24. b = a >> 1;
  25. a = b % 10;
  26. a = b == c;
  27. b = a | c;
  28. a = !b;
  29. b = a + c;
  30. a = b > c;
  31. }
  32. }
  33. printf("a=%d\n", a);
  34. }
  35.