3232* Prints the TAP version.
3333*/
3434static void print_version ( void ) {
35- printf ( "TAP version 13\n" );
35+ printf ( "TAP version 13\n" );
3636}
3737
3838/**
3939* Prints the TAP summary.
4040*
41- * @param total total number of tests
41+ * @param total total number of tests
4242* @param passing total number of passing tests
4343*/
4444static void print_summary ( int total , int passing ) {
45- printf ( "#\n" );
46- printf ( "1..%d\n" , total ); // TAP plan
47- printf ( "# total %d\n" , total );
48- printf ( "# pass %d\n" , passing );
49- printf ( "#\n" );
50- printf ( "# ok\n" );
45+ printf ( "#\n" );
46+ printf ( "1..%d\n" , total ); // TAP plan
47+ printf ( "# total %d\n" , total );
48+ printf ( "# pass %d\n" , passing );
49+ printf ( "#\n" );
50+ printf ( "# ok\n" );
5151}
5252
5353/**
@@ -56,12 +56,12 @@ static void print_summary( int total, int passing ) {
5656* @param elapsed elapsed time in seconds
5757*/
5858static void print_results ( double elapsed ) {
59- double rate = (double )ITERATIONS / elapsed ;
60- printf ( " ---\n" );
61- printf ( " iterations: %d\n" , ITERATIONS );
62- printf ( " elapsed: %0.9f\n" , elapsed );
63- printf ( " rate: %0.9f\n" , rate );
64- printf ( " ...\n" );
59+ double rate = (double )ITERATIONS / elapsed ;
60+ printf ( " ---\n" );
61+ printf ( " iterations: %d\n" , ITERATIONS );
62+ printf ( " elapsed: %0.9f\n" , elapsed );
63+ printf ( " rate: %0.9f\n" , rate );
64+ printf ( " ...\n" );
6565}
6666
6767/**
@@ -70,21 +70,21 @@ static void print_results( double elapsed ) {
7070* @return clock time
7171*/
7272static double tic ( void ) {
73- struct timeval now ;
74- gettimeofday ( & now , NULL );
75- return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
73+ struct timeval now ;
74+ gettimeofday ( & now , NULL );
75+ return (double )now .tv_sec + (double )now .tv_usec /1.0e6 ;
7676}
7777
7878/**
7979* Generates a random number on the interval [min,max).
8080*
81- * @param min minimum value (inclusive)
82- * @param max maximum value (exclusive)
83- * @return random number
81+ * @param min minimum value (inclusive)
82+ * @param max maximum value (exclusive)
83+ * @return random number
8484*/
8585static double random_uniform ( const double min , const double max ) {
86- double v = (double )rand () / ( (double )RAND_MAX + 1.0 );
87- return min + ( v * (max - min ) );
86+ double v = (double )rand () / ( (double )RAND_MAX + 1.0 );
87+ return min + ( v * (max - min ) );
8888}
8989
9090/**
@@ -93,49 +93,49 @@ static double random_uniform( const double min, const double max ) {
9393* @return elapsed time in seconds
9494*/
9595static double benchmark ( void ) {
96- double elapsed ;
97- double mu [ 100 ];
98- double s [ 100 ];
99- double y ;
100- double t ;
101- int i ;
96+ double elapsed ;
97+ double mu [ 100 ];
98+ double s [ 100 ];
99+ double y ;
100+ double t ;
101+ int i ;
102102
103- for ( i = 0 ; i < 100 ; i ++ ) {
104- mu [ i ] = random_uniform ( 0.0 , 100.0 ) - 50.0 ;
105- s [ i ] = random_uniform ( 0.0 , 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS ;
106- }
103+ for ( i = 0 ; i < 100 ; i ++ ) {
104+ mu [ i ] = random_uniform ( 0.0 , 100.0 ) - 50.0 ;
105+ s [ i ] = random_uniform ( 0.0 , 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS ;
106+ }
107107
108- t = tic ();
109- for ( i = 0 ; i < ITERATIONS ; i ++ ) {
110- y = stdlib_base_dists_logistic_skewness ( mu [ i % 100 ], s [ i % 100 ] );
111- if ( y != y ) {
112- printf ( "should not return NaN\n" );
113- break ;
114- }
115- }
116- elapsed = tic () - t ;
117- if ( y != y ) {
118- printf ( "should not return NaN\n" );
119- }
120- return elapsed ;
108+ t = tic ();
109+ for ( i = 0 ; i < ITERATIONS ; i ++ ) {
110+ y = stdlib_base_dists_logistic_skewness ( mu [ i % 100 ], s [ i % 100 ] );
111+ if ( y != y ) {
112+ printf ( "should not return NaN\n" );
113+ break ;
114+ }
115+ }
116+ elapsed = tic () - t ;
117+ if ( y != y ) {
118+ printf ( "should not return NaN\n" );
119+ }
120+ return elapsed ;
121121}
122122
123123/**
124124* Main execution sequence.
125125*/
126126int main ( void ) {
127- double elapsed ;
128- int i ;
127+ double elapsed ;
128+ int i ;
129129
130- // Use the current time to seed the random number generator:
131- srand ( time ( NULL ) );
130+ // Use the current time to seed the random number generator:
131+ srand ( time ( NULL ) );
132132
133- print_version ();
134- for ( i = 0 ; i < REPEATS ; i ++ ) {
135- printf ( "# c::%s\n" , NAME );
136- elapsed = benchmark ();
137- print_results ( elapsed );
138- printf ( "ok %d benchmark finished\n" , i + 1 );
139- }
140- print_summary ( REPEATS , REPEATS );
133+ print_version ();
134+ for ( i = 0 ; i < REPEATS ; i ++ ) {
135+ printf ( "# c::%s\n" , NAME );
136+ elapsed = benchmark ();
137+ print_results ( elapsed );
138+ printf ( "ok %d benchmark finished\n" , i + 1 );
139+ }
140+ print_summary ( REPEATS , REPEATS );
141141}
0 commit comments