home *** CD-ROM | disk | FTP | other *** search
-
- 1 /* benchreg - benchmark for register 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 register
- 9 #define TYPE int
- 10 #include <stdio.h>
- 11 main(ac, av)
- 12 int ac;
- 13 char *av[];
- 14 {
- 15 STOR_CL TYPE a, b, c;
- 16 long d, major, atol();
- 17 static TYPE m[10] = {0};
- 18
- 19 major = atol(av[1]);
- 20 printf("executing %ld iterations\n", major);
- 21 a = b = (av[1][0] - '0');
- 22 for (d = 1; d <= major; ++d)
- 23 {
- 24 /* inner loop executes 1000 selected operations */
- 25 for (c = 1; c <= 40; ++c)
- 26 {
- 27 a = a + b + c;
- 28 b = a >> 1;
- 29 a = b % 10;
- 30 m[a] = a;
- 31 b = m[a] - b - c;
- 32 a = b == c;
- 33 b = a | c;
- 34 a = !b;
- 35 b = a + c;
- 36 a = b > c;
- 37 }
- 38 }
- 39 printf("a=%d\n", a);
- 40 }