Skip to content

Commit e499000

Browse files
committed
style: fix spacing in C benchmark for planck/mgf
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent d142a52 commit e499000

File tree

1 file changed

+37
-37
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/planck/mgf/benchmark/c

1 file changed

+37
-37
lines changed

lib/node_modules/@stdlib/stats/base/dists/planck/mgf/benchmark/c/benchmark.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
/**
3131
* Prints the TAP version.
3232
*/
33-
static void print_version(void) {
34-
printf("TAP version 13\n");
33+
static void print_version( void ) {
34+
printf( "TAP version 13\n" );
3535
}
3636

3737
/**
@@ -40,37 +40,37 @@ static void print_version(void) {
4040
* @param total total number of tests
4141
* @param passing total number of passing tests
4242
*/
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");
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" );
5050
}
5151

5252
/**
5353
* Prints benchmarks results.
5454
*
5555
* @param elapsed elapsed time in seconds
5656
*/
57-
static void print_results(double elapsed) {
57+
static void print_results( double elapsed ) {
5858
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");
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
/**
6767
* Returns a clock time.
6868
*
6969
* @return clock time
7070
*/
71-
static double tic(void) {
71+
static double tic( void ) {
7272
struct timeval now;
73-
gettimeofday(&now, NULL);
73+
gettimeofday( &now, NULL );
7474
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
7575
}
7676

@@ -81,40 +81,40 @@ static double tic(void) {
8181
* @param max maximum value (exclusive)
8282
* @return random number
8383
*/
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));
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 ) );
8787
}
8888

8989
/**
9090
* Runs a benchmark.
9191
*
9292
* @return elapsed time in seconds
9393
*/
94-
static double benchmark(void) {
94+
static double benchmark( void ) {
9595
double elapsed;
9696
double t[100];
9797
double lambda[100];
9898
double y;
9999
int i;
100100

101-
for (i = 0; i < 100; i++) {
102-
t[i] = random_uniform(0.0, 10.0);
103-
lambda[i] = random_uniform(0.1, 10.0);
101+
for ( i = 0; i < 100; i++ ) {
102+
t[i] = random_uniform( 0.0, 10.0 );
103+
lambda[i] = random_uniform( 0.1, 10.0 );
104104
}
105105

106106
elapsed = tic();
107-
for (i = 0; i < ITERATIONS; i++) {
108-
y = stdlib_base_dists_planck_mgf(t[i % 100], lambda[i % 100]);
109-
if (isnan(y)) {
110-
printf("should not return NaN\n");
107+
for ( i = 0; i < ITERATIONS; i++ ) {
108+
y = stdlib_base_dists_planck_mgf( t[i % 100], lambda[i % 100] );
109+
if ( isnan( y ) ) {
110+
printf( "should not return NaN\n" );
111111
break;
112112
}
113113
}
114114
elapsed = tic() - elapsed;
115115

116-
if (isnan(y)) {
117-
printf("should not return NaN\n");
116+
if ( isnan( y ) ) {
117+
printf( "should not return NaN\n" );
118118
}
119119

120120
return elapsed;
@@ -123,19 +123,19 @@ static double benchmark(void) {
123123
/**
124124
* Main execution sequence.
125125
*/
126-
int main(void) {
126+
int main( void ) {
127127
double elapsed;
128128
int i;
129129

130130
// Use the current time to seed the random number generator:
131-
srand(time(NULL));
131+
srand( time( NULL ) );
132132

133133
print_version();
134-
for (i = 0; i < REPEATS; i++) {
135-
printf("# c::%s\n", NAME);
134+
for ( i = 0; i < REPEATS; i++ ) {
135+
printf( "# c::%s\n", NAME );
136136
elapsed = benchmark();
137-
print_results(elapsed);
138-
printf("ok %d benchmark finished\n", i + 1);
137+
print_results( elapsed );
138+
printf( "ok %d benchmark finished\n", i + 1 );
139139
}
140-
print_summary(REPEATS, REPEATS);
140+
print_summary( REPEATS, REPEATS );
141141
}

0 commit comments

Comments
 (0)