3131* Prints the TAP version.
3232*/
3333void print_version () {
34- printf ( "TAP version 13\n" );
34+ printf ( "TAP version 13\n" );
3535}
3636
3737/**
@@ -41,12 +41,12 @@ void print_version() {
4141* @param passing total number of passing tests
4242*/
4343static void print_summary ( int total , int passing ) {
44- printf ( "#\n" );
45- printf ( "1..%d\n" , total ); // TAP plan
46- printf ( "# total %d\n" , total );
47- printf ( "# pass %d\n" , passing );
48- printf ( "#\n" );
49- printf ( "# ok\n" );
44+ printf ( "#\n" );
45+ printf ( "1..%d\n" , total ); // TAP plan
46+ printf ( "# total %d\n" , total );
47+ printf ( "# pass %d\n" , passing );
48+ printf ( "#\n" );
49+ printf ( "# ok\n" );
5050}
5151
5252/**
@@ -55,12 +55,12 @@ static void print_summary( int total, int passing ) {
5555* @param elapsed elapsed time in seconds
5656*/
5757static void print_results ( double elapsed ) {
58- double rate = (double )ITERATIONS / elapsed ;
59- printf ( " ---\n" );
60- printf ( " iterations: %d\n" , ITERATIONS );
61- printf ( " elapsed: %0.9f\n" , elapsed );
62- printf ( " rate: %0.9f\n" , rate );
63- printf ( " ...\n" );
58+ double rate = (double )ITERATIONS / elapsed ;
59+ printf ( " ---\n" );
60+ printf ( " iterations: %d\n" , ITERATIONS );
61+ printf ( " elapsed: %0.9f\n" , elapsed );
62+ printf ( " rate: %0.9f\n" , rate );
63+ printf ( " ...\n" );
6464}
6565
6666/**
@@ -69,9 +69,9 @@ static void print_results( double elapsed ) {
6969* @return clock time
7070*/
7171static double tic ( void ) {
72- struct timeval now ;
73- gettimeofday ( & now , NULL );
74- return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
72+ struct timeval now ;
73+ gettimeofday ( & now , NULL );
74+ return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
7575}
7676
7777/**
@@ -80,8 +80,8 @@ static double tic( void ) {
8080* @return random number
8181*/
8282static float rand_float ( void ) {
83- int r = rand ();
84- return (float )r / ( (float )RAND_MAX + 1.0f );
83+ int r = rand ();
84+ return (float )r / ( (float )RAND_MAX + 1.0f );
8585}
8686
8787/**
@@ -90,47 +90,47 @@ static float rand_float( void ) {
9090* @return elapsed time in seconds
9191*/
9292static double benchmark ( void ) {
93- double elapsed ;
94- int32_t x [ 100 ];
95- double t ;
96- float y ;
97- int i ;
93+ double elapsed ;
94+ int32_t x [ 100 ];
95+ double t ;
96+ float y ;
97+ int i ;
9898
9999 for ( i = 0 ; i < 100 ; i ++ ) {
100100 x [ i ] = ( int32_t )( 34.0f * rand_float () );
101101 }
102102
103- t = tic ();
104- for ( i = 0 ; i < ITERATIONS ; i ++ ) {
105- y = stdlib_base_lucasf ( x [ i % 100 ] );
106- if ( y != y ) {
107- printf ( "should not return NaN\n" );
108- break ;
109- }
110- }
111- elapsed = tic () - t ;
112- if ( y != y ) {
113- printf ( "should not return NaN\n" );
114- }
115- return elapsed ;
103+ t = tic ();
104+ for ( i = 0 ; i < ITERATIONS ; i ++ ) {
105+ y = stdlib_base_lucasf ( x [ i % 100 ] );
106+ if ( y != y ) {
107+ printf ( "should not return NaN\n" );
108+ break ;
109+ }
110+ }
111+ elapsed = tic () - t ;
112+ if ( y != y ) {
113+ printf ( "should not return NaN\n" );
114+ }
115+ return elapsed ;
116116}
117117
118118/**
119119* Main execution sequence.
120120*/
121121int main ( void ) {
122- double elapsed ;
123- int i ;
122+ double elapsed ;
123+ int i ;
124124
125- // Use the current time to seed the random number generator:
126- srand ( time ( NULL ) );
125+ // Use the current time to seed the random number generator:
126+ srand ( time ( NULL ) );
127127
128- print_version ();
129- for ( i = 0 ; i < REPEATS ; i ++ ) {
130- printf ( "# c::native::%s\n" , NAME );
131- elapsed = benchmark ();
132- print_results ( elapsed );
133- printf ( "ok %d benchmark finished\n" , i + 1 );
134- }
135- print_summary ( REPEATS , REPEATS );
128+ print_version ();
129+ for ( i = 0 ; i < REPEATS ; i ++ ) {
130+ printf ( "# c::native::%s\n" , NAME );
131+ elapsed = benchmark ();
132+ print_results ( elapsed );
133+ printf ( "ok %d benchmark finished\n" , i + 1 );
134+ }
135+ print_summary ( REPEATS , REPEATS );
136136}
0 commit comments