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,8 +80,8 @@ static double tic( void ) {
8080* @return random number
8181*/
8282static double rand_double ( void ) {
83- int r = rand ();
84- return (double )r / ( (double )RAND_MAX + 1.0 );
83+ int r = rand ();
84+ return (double )r / ( (double )RAND_MAX + 1.0 );
8585}
8686
8787/**
@@ -90,7 +90,7 @@ static double rand_double( void ) {
9090* @return random integer
9191*/
9292static int rand_int ( void ) {
93- return (rand () % 100 ) + 1 ;
93+ return (rand () % 100 ) + 1 ;
9494}
9595
9696/**
@@ -99,49 +99,49 @@ static int rand_int( void ) {
9999* @return elapsed time in seconds
100100*/
101101static double benchmark ( void ) {
102- double elapsed ;
103- double p [ 100 ];
104- int n [ 100 ];
105- double y ;
106- double t ;
107- int i ;
102+ double elapsed ;
103+ double p [ 100 ];
104+ int n [ 100 ];
105+ double y ;
106+ double t ;
107+ int i ;
108108
109- for ( i = 0 ; i < 100 ; i ++ ) {
110- p [ i ] = rand_double ();
111- n [ i ] = rand_int ();
112- }
109+ for ( i = 0 ; i < 100 ; i ++ ) {
110+ p [ i ] = rand_double ();
111+ n [ i ] = rand_int ();
112+ }
113113
114- t = tic ();
115- for ( i = 0 ; i < ITERATIONS ; i ++ ) {
116- y = stdlib_base_dists_binomial_median ( n [ i %100 ], p [ i %100 ] );
117- if ( y != y ) {
118- printf ( "should not return NaN\n" );
119- break ;
120- }
121- }
122- elapsed = tic () - t ;
123- if ( y != y ) {
124- printf ( "should not return NaN\n" );
125- }
126- return elapsed ;
114+ t = tic ();
115+ for ( i = 0 ; i < ITERATIONS ; i ++ ) {
116+ y = stdlib_base_dists_binomial_median ( n [ i %100 ], p [ i %100 ] );
117+ if ( y != y ) {
118+ printf ( "should not return NaN\n" );
119+ break ;
120+ }
121+ }
122+ elapsed = tic () - t ;
123+ if ( y != y ) {
124+ printf ( "should not return NaN\n" );
125+ }
126+ return elapsed ;
127127}
128128
129129/**
130130* Main execution sequence.
131131*/
132132int main ( void ) {
133- double elapsed ;
134- int i ;
133+ double elapsed ;
134+ int i ;
135135
136- // Use the current time to seed the random number generator:
137- srand ( time ( NULL ) );
136+ // Use the current time to seed the random number generator:
137+ srand ( time ( NULL ) );
138138
139- print_version ();
140- for ( i = 0 ; i < REPEATS ; i ++ ) {
141- printf ( "# c::%s\n" , NAME );
142- elapsed = benchmark ();
143- print_results ( elapsed );
144- printf ( "ok %d benchmark finished\n" , i + 1 );
145- }
146- print_summary ( REPEATS , REPEATS );
139+ print_version ();
140+ for ( i = 0 ; i < REPEATS ; i ++ ) {
141+ printf ( "# c::%s\n" , NAME );
142+ elapsed = benchmark ();
143+ print_results ( elapsed );
144+ printf ( "ok %d benchmark finished\n" , i + 1 );
145+ }
146+ print_summary ( REPEATS , REPEATS );
147147}
0 commit comments