home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / byteunix.lzh / byte.1 / arith.c next >
C/C++ Source or Header  |  1990-05-11  |  2KB  |  77 lines

  1.  
  2. /*******************************************************************************
  3.  *  The BYTE UNIX Benchmarks - Release 2
  4.  *          Module: arith.c   SID: 2.4 4/17/90 16:45:31
  5.  *          
  6.  *******************************************************************************
  7.  * Bug reports, patches, comments, suggestions should be sent to:
  8.  *
  9.  *    Ben Smith or Rick Grehan at BYTE Magazine
  10.  *    bensmith@bixpb.UUCP    rick_g@bixpb.UUCP
  11.  *
  12.  *******************************************************************************
  13.  *  Modification Log:
  14.  *  May 12, 1989 - modified empty loops to avoid nullifying by optimizing
  15.  *                 compilers
  16.  *
  17.  ******************************************************************************/
  18.  
  19. char SCCSid[] = "@(#) @(#)arith.c:2.4 -- 4/17/90 16:45:31";
  20. /*
  21.  *  arithmetic test
  22.  *
  23.  */
  24.  
  25. main(argc, argv)
  26. int    argc;
  27. char    *argv[];
  28. {
  29.     int    iter;
  30.     int    i;
  31.     int result;
  32.  
  33.     if (argc != 2) {
  34.         printf("Usage: %s count\n", argv[0]);
  35.         exit(1);
  36.     }
  37.  
  38.     iter = atoi(argv[1]);
  39.  
  40.     while (iter-- > 0) 
  41.     {
  42.     /* the loop calls a function to insure that something is done */
  43.     /* the results of the function are thrown away. But a loop with */
  44.     /* unused assignments may get optimized out of existence */
  45.     result = dumb_stuff(i);
  46.     }
  47.     exit(0);
  48. }
  49.  
  50.  
  51. /************************** dumb_stuff *******************/
  52. dumb_stuff(i)
  53. int i;
  54. {
  55. #ifndef arithoh
  56.     datum    x, y, z;
  57.         z = 0;
  58. #endif
  59.         /*
  60.          *     101
  61.          * sum       i*i/(i*i-1)
  62.          *     i=2
  63.          */
  64.         for (i=2; i<=101; i++) 
  65.             {
  66. #ifndef arithoh
  67.             x = i;
  68.             y = x*x;
  69.             z += y/(y-1);
  70.             }
  71. return(x+y+z);
  72. #else
  73.             }
  74. return(0);
  75. #endif
  76. }
  77.