home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / formu220.zip / time.doc < prev   
Text File  |  1995-05-17  |  3KB  |  87 lines

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