3131* Prints the TAP version.
3232*/
3333static void print_version ( void ) {
34- printf ( "TAP version 13\n" );
34+ printf ( "TAP version 13\n" );
3535}
3636
3737/**
3838* Prints the TAP summary.
3939*
40- * @param total total number of tests
41- * @param passing total number of passing tests
40+ * @param total total number of tests
41+ * @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,45 +80,45 @@ static double tic( void ) {
8080* @return elapsed time in seconds
8181*/
8282static double benchmark ( void ) {
83- double elapsed ;
84- double a , b ;
85- double y ;
86- double t ;
87- int i ;
83+ double elapsed ;
84+ double a , b ;
85+ double y ;
86+ double t ;
87+ int i ;
8888
89- t = tic ();
90- for ( i = 0 ; i < ITERATIONS ; i ++ ) {
91- a = ( (double )rand () / (double )RAND_MAX ) * 100.0 ; // Random lower bound between 0 and 100
92- b = a + ( (double )rand () / (double )RAND_MAX ) * 100.0 ; // Random upper bound greater than a
93- y = stdlib_base_dists_uniform_median ( a , b );
94- if ( y != y ) {
95- printf ( "should not return NaN\n" );
96- break ;
97- }
98- }
99- elapsed = tic () - t ;
100- if ( y != y ) {
101- printf ( "should not return NaN\n" );
102- }
103- return elapsed ;
89+ t = tic ();
90+ for ( i = 0 ; i < ITERATIONS ; i ++ ) {
91+ a = ( (double )rand () / (double )RAND_MAX ) * 100.0 ; // Random lower bound between 0 and 100
92+ b = a + ( (double )rand () / (double )RAND_MAX ) * 100.0 ; // Random upper bound greater than a
93+ y = stdlib_base_dists_uniform_median ( a , b );
94+ if ( y != y ) {
95+ printf ( "should not return NaN\n" );
96+ break ;
97+ }
98+ }
99+ elapsed = tic () - t ;
100+ if ( y != y ) {
101+ printf ( "should not return NaN\n" );
102+ }
103+ return elapsed ;
104104}
105105
106106/**
107107* Main execution sequence.
108108*/
109109int main ( void ) {
110- double elapsed ;
111- int i ;
110+ double elapsed ;
111+ int i ;
112112
113- // Use the current time to seed the random number generator:
114- srand ( time ( NULL ) );
113+ // Use the current time to seed the random number generator:
114+ srand ( time ( NULL ) );
115115
116- print_version ();
117- for ( i = 0 ; i < REPEATS ; i ++ ) {
118- printf ( "# c::%s\n" , NAME );
119- elapsed = benchmark ();
120- print_results ( elapsed );
121- printf ( "ok %d benchmark finished\n" , i + 1 );
122- }
123- print_summary ( REPEATS , REPEATS );
116+ print_version ();
117+ for ( i = 0 ; i < REPEATS ; i ++ ) {
118+ printf ( "# c::%s\n" , NAME );
119+ elapsed = benchmark ();
120+ print_results ( elapsed );
121+ printf ( "ok %d benchmark finished\n" , i + 1 );
122+ }
123+ print_summary ( REPEATS , REPEATS );
124124}
0 commit comments