132 #if defined(ECL_IS_WIN32)   141      p[2] = (double)GetTickCount() * 1.0e-03;
   146 #elif defined(ECL_IS_POSIX)   149     #include <sys/times.h>   153         static struct tms tms;
   158         p[2] = (double)tms.tms_utime / (
double)_SC_CLK_TCK;
   168 int main(
int argc, 
char** argv)
   176     CmdLine cmd(
"Benchmarks the speed of computation (mflops) on this machine.");
   177     cmd.
parse(argc,argv);
   183     double nulltime, TimeArray[3];   
   190     double sa,sb,sc,one,two,three;
   192     double four,five,piref,piprg;
   196     double A1 = -0.1666666666671334;
   197     double A2 = 0.833333333809067E-2;
   198     double A3 = 0.198412715551283E-3;
   199     double A4 = 0.27557589750762E-5;
   200     double A5 = 0.2507059876207E-7;
   201     double A6 = 0.164105986683E-9;
   204     double B1 = -0.4999999999982;
   205     double B2 = 0.4166666664651E-1;
   206     double B3 = -0.1388888805755E-2;
   207     double B4 = 0.24801428034E-4;
   208     double B5 = -0.2754213324E-6;
   209     double B6 = 0.20189405E-8;
   221     double D1 = 0.3999999946405E-1;
   223     double D3 = 0.1233153E-5;
   226     double E3 = 0.411051E-6;
   231    register long i, m, n;
   234    printf(
"   FLOPS C Program (Double Precision), V2.0 18 Dec 1992\n\n");
   255    T[1] = 1.0E+06/(double)loops;
   260    piref = 3.14159265358979324;
   268    printf(
"   Module     Error        RunTime      MFLOPS    Math Calculation     Operations\n");
   291    while ( sa < TLimit )
   300        for( i = 1 ; i <= n-1 ; i++ )
   304        s = s + (D1+u*(D2+u*D3))/(w+u*(D1+u*(E2+u*E3)));
   309    if ( n == NLimit ) 
break;
   313    scale = 1.0E+06 / (double)n;
   320    for( i = 1 ; i <= n-1 ; i++ )
   324    nulltime = T[1] * TimeArray[1];
   325    if ( nulltime < 0.0 ) nulltime = 0.0;
   327    T[2] = T[1] * sa - nulltime;
   329    sa = (D1+D2+D3)/(one+D1+E2+E3);
   333    sa = x * ( sa + sb + two * s ) / two;           
   335    n  = (long)( (
double)( 40000 * (long)sb ) / scale );
   342    printf(
"     1   %13.4le  %10.4lf  %10.4lf    Integration                      [ 7+, 0-, 6*, 1/]\n",sc,T[2],T[4]);
   359    for ( i = 1 ; i <= m ; i++ )
   365    T[5] = T[1] * TimeArray[1];
   366    if ( T[5] < 0.0 ) T[5] = 0.0;
   376    for ( i = 1 ; i <= m ; i++)
   386    T[6] = T[1] * TimeArray[1];
   388    T[7] = ( T[6] - T[5] ) / 7.0;                   
   389    m  = (long)( sa * x  / sc );                    
   390    sa = four * w / five;                           
   393    piprg = sb - sc / (v * v * v);
   394    pierr = piprg - piref;
   400    printf(
"     2   %13.4le  %10.4lf  %10.4lf    Taylor Series                    [ 3+, 2-, 1*, 1/]\n",pierr,T[6]-T[5],T[8]);
   411    x = piref / ( three * (double)m );              
   416    for( i = 1 ; i <= m-1 ; i++ )
   421    s = s + u * ((((((A6*w-A5)*w+A4)*w-A3)*w+A2)*w+A1)*w+one);
   424    T[9]  = T[1] * TimeArray[1] - nulltime;
   428    sa = u * ((((((A6*w-A5)*w+A4)*w-A3)*w+A2)*w+A1)*w+one);
   431    sa = x * ( sa + two * s ) / two;                
   439    printf(
"     3   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (sin)            [ 6+, 2-, 9*, 0/]\n",sc,T[9],T[11]);
   451    x = piref / ( three * (double)m );              
   456    for( i = 1 ; i <= m-1 ; i++ )
   460    s = s + w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   463    T[12]  = T[1] * TimeArray[1] - nulltime;
   467    sa = w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   469    T[13] = T[12] / 15.0;                             
   470    sa = x * ( sa + one + two * s ) / two;            
   473    sb = u * ((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+A0);
   480    printf(
"     4   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (cos)            [ 7+, 0-, 8*, 0/]\n",sc,T[12],T[14]);
   491    x = piref / ( three * (double)m );              
   496    for( i = 1 ; i <= m-1 ; i++ )
   500    v = u * ((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   501    s = s + v / (w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one);
   504    T[15]  = T[1] * TimeArray[1] - nulltime;
   508    sa = u*((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   509    sb = w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   512    T[16] = T[15] / 29.0;                             
   513    sa = x * ( sa + two * s ) / two;                  
   514    sb = 0.6931471805599453;                          
   521    printf(
"     5   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (tan)            [13+, 0-,15*, 1/]\n",sc,T[15],T[17]);
   532    x = piref / ( four * (double)m );               
   537    for( i = 1 ; i <= m-1 ; i++ )
   541    v = u * ((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   542    s = s + v*(w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one);
   545    T[18]  = T[1] * TimeArray[1] - nulltime;
   549    sa = u*((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   550    sb = w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   553    T[19] = T[18] / 29.0;                             
   554    sa = x * ( sa + two * s ) / two;                  
   562    printf(
"     6   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (sin*cos)        [13+, 0-,16*, 0/]\n",sc,T[18],T[20]);
   578    sa = 102.3321513995275;
   582    for ( i = 1 ; i <= m-1 ; i++)
   586    s = s - w / ( x + w ) - x / ( u + w ) - u / ( x * u + w );
   589    T[21] = T[1] * TimeArray[1] - nulltime;
   593    T[22] = T[21] / 12.0;
   596    sa = -w - w / ( x + w ) - x / ( u + w ) - u / ( x * u + w );
   597    sa = 18.0 * v * (sa + two * s );
   599    m  = -2000 * (long)sa;
   600    m = (long)( (
double)m / scale );
   608    printf(
"     7   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (polynomial)     [ 3+, 3-, 3*, 3/]\n",sc,T[21],T[23]);
   620    x = piref / ( three * (double)m );              
   625    for( i = 1 ; i <= m-1 ; i++ )
   629    v = w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   630    s = s + v*v*u*((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   633    T[24]  = T[1] * TimeArray[1] - nulltime;
   637    sa = u*((((((A6*w+A5)*w+A4)*w+A3)*w+A2)*w+A1)*w+one);
   638    sb = w*(w*(w*(w*(w*(B6*w+B5)+B4)+B3)+B2)+B1)+one;
   641    T[25] = T[24] / 30.0;                             
   642    sa = x * ( sa + two * s ) / two;                  
   643    sb = 0.29166666666666667;                         
   650    printf(
"     8   %13.4le  %10.4lf  %10.4lf    Trapezoidal Sum (sin*cos*cos)    [13+, 0-,17*, 0/]\n",sc,T[24],T[26]);
   657    T[27] = ( five * (T[6] - T[5]) + T[9] ) / 52.0;
   664    T[29] = T[2] + T[9] + T[12] + T[15] + T[18];
   665    T[29] = (T[29] + four * T[21]) / 152.0;
   672    T[31] = T[2] + T[9] + T[12] + T[15] + T[18];
   673    T[31] = (T[31] + T[21] + T[24]) / 146.0;
   680    T[33] = (T[9] + T[12] + T[18] + T[24]) / 91.0;
   685    printf(
"Averaging various groups above\n");
   687    printf(
"   Iterations      = %10ld\n",m);
   688    printf(
"   NullTime (usec) = %10.4lf\n",nulltime);
   689    printf(
"   MFLOPS(1)       = %10.4lf    [generic 2,3 only]\n",T[28]);
   690    printf(
"   MFLOPS(2)       = %10.4lf    [9.2%% fp divisions]\n",T[30]);
   691    printf(
"   MFLOPS(3)       = %10.4lf    [3.4%% fp divisions]\n",T[32]);
   692    printf(
"   MFLOPS(4)       = %10.4lf    [0.0%% fp divisions]\n\n",T[34]);
 
int main(int argc, char **argv)
void parse(int argc, char **argv)