3535
3636typedef double (* function1 )(double );
3737
38- void bench (const char * expr , function1 func ) {
38+ static void bench (const char * expr , function1 func ) {
3939 int i , j ;
4040 volatile double d ;
4141 double tmp ;
4242 clock_t start ;
4343
44- te_variable lk = {"a" , {& tmp }};
44+ te_variable lk = {"a" , {& tmp }, TE_VARIABLE , NULL };
4545
4646 printf ("Expression: %s\n" , expr );
4747
@@ -53,12 +53,12 @@ void bench(const char *expr, function1 func) {
5353 tmp = i ;
5454 d += func (tmp );
5555 }
56- const int nelapsed = (clock () - start ) * 1000 / CLOCKS_PER_SEC ;
56+ const long int nelapsed = (clock () - start ) * 1000 / CLOCKS_PER_SEC ;
5757
5858 /*Million floats per second input.*/
5959 printf (" %.5g" , d );
6060 if (nelapsed )
61- printf ("\t%5dms \t%5dmfps \n" , nelapsed , loops * loops / nelapsed / 1000 );
61+ printf ("\t%5ldms \t%5ldmfps \n" , nelapsed , loops * loops / nelapsed / 1000 );
6262 else
6363 printf ("\tinf\n" );
6464
@@ -74,47 +74,47 @@ void bench(const char *expr, function1 func) {
7474 tmp = i ;
7575 d += te_eval (n );
7676 }
77- const int eelapsed = (clock () - start ) * 1000 / CLOCKS_PER_SEC ;
77+ const long int eelapsed = (clock () - start ) * 1000 / CLOCKS_PER_SEC ;
7878 te_free (n );
7979
8080 /*Million floats per second input.*/
8181 printf (" %.5g" , d );
8282 if (eelapsed )
83- printf ("\t%5dms \t%5dmfps \n" , eelapsed , loops * loops / eelapsed / 1000 );
83+ printf ("\t%5ldms \t%5ldmfps \n" , eelapsed , loops * loops / eelapsed / 1000 );
8484 else
8585 printf ("\tinf\n" );
8686
8787
88- printf ("%.2f%% longer\n" , (((double )eelapsed / nelapsed ) - 1.0 ) * 100.0 );
88+ printf ("%.2f%% longer\n" , (((double )eelapsed / ( double ) nelapsed ) - 1.0 ) * 100.0 );
8989
9090
9191 printf ("\n" );
9292}
9393
9494
95- double a5 (double a ) {
95+ static double a5 (double a ) {
9696 return a + 5 ;
9797}
9898
99- double a52 (double a ) {
99+ static double a52 (double a ) {
100100 return (a + 5 )* 2 ;
101101}
102102
103- double a10 (double a ) {
103+ static double a10 (double a ) {
104104 return a + (5 * 2 );
105105}
106106
107- double as (double a ) {
107+ static double as (double a ) {
108108 return sqrt (pow (a , 1.5 ) + pow (a , 2.5 ));
109109}
110110
111- double al (double a ) {
111+ static double al (double a ) {
112112 return (1 /(a + 1 )+ 2 /(a + 2 )+ 3 /(a + 3 ));
113113}
114114
115115int main (int argc , char * argv [])
116116{
117-
117+ ( void ) argc ; ( void ) argv ;
118118 bench ("sqrt(a^1.5+a^2.5)" , as );
119119 bench ("a+5" , a5 );
120120 bench ("a+(5*2)" , a10 );
0 commit comments