31
31
* Prints the TAP version.
32
32
*/
33
33
static void print_version ( void ) {
34
- printf ( "TAP version 13\n" );
34
+ printf ( "TAP version 13\n" );
35
35
}
36
36
37
37
/**
@@ -41,12 +41,12 @@ static void print_version( void ) {
41
41
* @param passing total number of passing tests
42
42
*/
43
43
static 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" );
50
50
}
51
51
52
52
/**
@@ -55,12 +55,12 @@ static void print_summary( int total, int passing ) {
55
55
* @param elapsed elapsed time in seconds
56
56
*/
57
57
static 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" );
64
64
}
65
65
66
66
/**
@@ -69,9 +69,9 @@ static void print_results( double elapsed ) {
69
69
* @return clock time
70
70
*/
71
71
static 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 ;
75
75
}
76
76
77
77
/**
@@ -82,8 +82,8 @@ static double tic( void ) {
82
82
* @return random number
83
83
*/
84
84
static double random_uniform ( const double min , const double max ) {
85
- double v = (double )rand () / ( (double )RAND_MAX + 1.0 );
86
- return min + ( v * (max - min ) );
85
+ double v = (double )rand () / ( (double )RAND_MAX + 1.0 );
86
+ return min + ( v * (max - min ) );
87
87
}
88
88
89
89
/**
@@ -92,54 +92,54 @@ static double random_uniform( const double min, const double max ) {
92
92
* @return elapsed time in seconds
93
93
*/
94
94
static double benchmark ( void ) {
95
- double elapsed ;
96
- double k [ 100 ];
97
- double lambda [ 100 ];
98
- double y ;
99
- double t ;
100
- int i ;
95
+ double elapsed ;
96
+ double k [ 100 ];
97
+ double lambda [ 100 ];
98
+ double y ;
99
+ double t ;
100
+ int i ;
101
101
102
- // Generate random values for k (shape) and lambda (scale)
103
- for ( i = 0 ; i < 100 ; i ++ ) {
104
- k [ i ] = random_uniform ( 0.1 , 10.0 ); // k > 0 to avoid NaN result
105
- lambda [ i ] = random_uniform ( 0.1 , 10.0 ); // lambda > 0 to avoid NaN result
106
- }
102
+ // Generate random values for k (shape) and lambda (scale)
103
+ for ( i = 0 ; i < 100 ; i ++ ) {
104
+ k [ i ] = random_uniform ( 0.1 , 10.0 ); // k > 0 to avoid NaN result
105
+ lambda [ i ] = random_uniform ( 0.1 , 10.0 ); // lambda > 0 to avoid NaN result
106
+ }
107
107
108
- t = tic ();
109
- // Benchmark loop
110
- for ( i = 0 ; i < ITERATIONS ; i ++ ) {
111
- // Calculate skewness for the Weibull distribution
112
- y = stdlib_base_dists_weibull_skewness ( k [ i % 100 ], lambda [ i % 100 ] );
113
- if ( y != y ) { // Check for NaN
114
- printf ( "should not return NaN\n" );
115
- break ;
116
- }
117
- }
118
- elapsed = tic () - t ;
108
+ t = tic ();
109
+ // Benchmark loop
110
+ for ( i = 0 ; i < ITERATIONS ; i ++ ) {
111
+ // Calculate skewness for the Weibull distribution
112
+ y = stdlib_base_dists_weibull_skewness ( k [ i % 100 ], lambda [ i % 100 ] );
113
+ if ( y != y ) { // Check for NaN
114
+ printf ( "should not return NaN\n" );
115
+ break ;
116
+ }
117
+ }
118
+ elapsed = tic () - t ;
119
119
120
- // Final NaN check
121
- if ( y != y ) {
122
- printf ( "should not return NaN\n" );
123
- }
124
- return elapsed ;
120
+ // Final NaN check
121
+ if ( y != y ) {
122
+ printf ( "should not return NaN\n" );
123
+ }
124
+ return elapsed ;
125
125
}
126
126
127
127
/**
128
128
* Main execution sequence.
129
129
*/
130
130
int main ( void ) {
131
- double elapsed ;
132
- int i ;
131
+ double elapsed ;
132
+ int i ;
133
133
134
- // Use the current time to seed the random number generator:
135
- srand ( time ( NULL ) );
134
+ // Use the current time to seed the random number generator:
135
+ srand ( time ( NULL ) );
136
136
137
- print_version ();
138
- for ( i = 0 ; i < REPEATS ; i ++ ) {
139
- printf ( "# c::%s\n" , NAME );
140
- elapsed = benchmark ();
141
- print_results ( elapsed );
142
- printf ( "ok %d benchmark finished\n" , i + 1 );
143
- }
144
- print_summary ( REPEATS , REPEATS );
137
+ print_version ();
138
+ for ( i = 0 ; i < REPEATS ; i ++ ) {
139
+ printf ( "# c::%s\n" , NAME );
140
+ elapsed = benchmark ();
141
+ print_results ( elapsed );
142
+ printf ( "ok %d benchmark finished\n" , i + 1 );
143
+ }
144
+ print_summary ( REPEATS , REPEATS );
145
145
}
0 commit comments