home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / pcc / v08n03 / math.exe / PARSER21.ZIP / TIME.DOC < prev   
Text File  |  1994-07-28  |  3KB  |  78 lines

  1. A COMPARISON OF THE VELOCITIES OF C AND FORMULC IN A VAX , VMS 5.5 RUNNING CC
  2. - ---------- -- --- ---------- -- - --- ------- -- - --- - --- --- ------- --
  3.      AND IN A 80386SX, 16 Mhz PC WITHOUT A MATH COPROCESSOR RUNNING GCC 1.11
  4.      --- -- - -------- -- --- -- ------- - ---- ----------- ------- --- ----
  5.      (DJGPP, Free Software Foundation) 
  6.      ---------------------------------
  7.  
  8.      For this comparison, I used loops which repeated operations
  9. 500,000 to 1,000,000 times.
  10.  
  11.             double q,result;
  12.  
  13.             for(q=0.0; q<=5.0; q += 1E-5)
  14.              result=result;         /* almost-empty loop */
  15.      
  16.             for(q=0.0; q<=5.0; q += 1E-5)
  17.              result=sin(q);               /* C */
  18.  
  19.             for(q=0.0; q<=5.0; q += 1E-5)
  20.              result=f_val(my_function,"x",q);  /*FORMULA*/
  21.  
  22. ------------------------------------
  23.  
  24. x*x - 2*x + 1      
  25.  
  26.       VAX/VMS (when I am the only user)       80386SX, 16Mhz
  27.  
  28.            empty loop: 0.00014 ms              1.165 ms
  29.            C (without counting the loop time):
  30.                        0.00014 ms              1.230 ms
  31.            f_val     : 0.018 ms                3.054 ms
  32.            f_x_val   : 0.016 ms
  33.  
  34.                    FORMULA is weak at quadratics and other simple functions.
  35.  
  36. ------------------------------------
  37.  
  38. x^7       VAX (1 user)                       80386SX, 16 Mhz     
  39.  
  40.            C         : 0.024 ms               3.835 ms
  41.            f_val     : 0.036 ms               4.67  ms
  42.            f_x_val   : 0.036 ms
  43.  
  44.            This times are not too bad for an interpreter like FORMULA.
  45.  
  46. ------------------------------------
  47.  
  48. cos(x)    VAX (1 user)                       80386SX, 16Mhz
  49.  
  50.          C        : 0.019 ms                1.63 ms
  51.          f_val or                            
  52.          f_x_val  : 0.029 ms                2.47 ms
  53.  
  54. ------------------------------------
  55. exp(-x*x/2)/sqrt(2*3.14159265358979323)    (C)
  56. exp(-x*x/2)/sqrt(2*pi())         (FORMULA)
  57.                 
  58.                VAX (1 user)                  80386SX, 16 Mhz
  59.  
  60.             C      : 0.017 ms             4.85 ms    
  61.             f_val  : 0.029 ms             5.95 ms
  62.             f_x_val: 0.027 ms           
  63.  
  64.      Like most C compilers, FORMULA optimizes code by calculating
  65. constant expressions like sqrt(2*pi()) once only. 
  66.  
  67. --------------------------------------
  68.  
  69. exp(sin(x)) 
  70.                VAX (1 user)                  80386SX, 16 Mhz
  71.  
  72.             C      :0.024 ms                 4.50 ms
  73.             f_val  :0.024 ms                 5.37 ms             
  74.             f_x_val:0.024 ms
  75.  
  76.        FORMULA is extremely efficient when evaluating library and user-defined
  77. C functions.
  78.