diff --git a/lib/node_modules/@stdlib/stats/strided/smean/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/smean/benchmark/c/benchmark.length.c index 99767ea023a4..5e76850794e6 100644 --- a/lib/node_modules/@stdlib/stats/strided/smean/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/smean/benchmark/c/benchmark.length.c @@ -32,8 +32,8 @@ /** * Prints the TAP version. */ -static void print_version( void ) { - printf( "TAP version 13\n" ); +static void print_version(void) { + printf("TAP version 13\n"); } /** @@ -42,13 +42,13 @@ static void print_version( void ) { * @param total total number of tests * @param passing total number of passing tests */ -static void print_summary( int total, int passing ) { - printf( "#\n" ); - printf( "1..%d\n", total ); // TAP plan - printf( "# total %d\n", total ); - printf( "# pass %d\n", passing ); - printf( "#\n" ); - printf( "# ok\n" ); +static void print_summary(int total, int passing) { + printf("#\n"); + printf("1..%d\n", total); // TAP plan + printf("# total %d\n", total); + printf("# pass %d\n", passing); + printf("#\n"); + printf("# ok\n"); } /** @@ -57,13 +57,13 @@ static void print_summary( int total, int passing ) { * @param iterations number of iterations * @param elapsed elapsed time in seconds */ -static void print_results( int iterations, double elapsed ) { +static void print_results(int iterations, double elapsed) { double rate = (double)iterations / elapsed; - printf( " ---\n" ); - printf( " iterations: %d\n", iterations ); - printf( " elapsed: %0.9f\n", elapsed ); - printf( " rate: %0.9f\n", rate ); - printf( " ...\n" ); + printf(" ---\n"); + printf(" iterations: %d\n", iterations); + printf(" elapsed: %0.9f\n", elapsed); + printf(" rate: %0.9f\n", rate); + printf(" ...\n"); } /** @@ -71,10 +71,10 @@ static void print_results( int iterations, double elapsed ) { * * @return clock time */ -static double tic( void ) { +static double tic(void) { struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; + gettimeofday(&now, NULL); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; } /** @@ -82,9 +82,9 @@ static double tic( void ) { * * @return random number */ -static float rand_float( void ) { +static float rand_float(void) { int r = rand(); - return (float)r / ( (float)RAND_MAX + 1.0f ); + return (float)r / ((float)RAND_MAX + 1.0f); } /** @@ -94,36 +94,46 @@ static float rand_float( void ) { * @param len array length * @return elapsed time in seconds */ -static double benchmark( int iterations, int len ) { +static double benchmark(int iterations, int len) { double elapsed; - float x[ len ]; - float v; + float* x = malloc(len * sizeof(float)); + if (x == NULL) { + fprintf(stderr, "Memory allocation failed\n"); + exit(1); + } + + float v = 0.0f; double t; int i; - for ( i = 0; i < len; i++ ) { - x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; + for (i = 0; i < len; i++) { + x[i] = (rand_float() * 20000.0f) - 10000.0f; } - v = 0.0f; + t = tic(); - for ( i = 0; i < iterations; i++ ) { - v = stdlib_strided_smean( len, x, 1 ); - if ( v != v ) { - printf( "should not return NaN\n" ); + for (i = 0; i < iterations; i++) { + v = stdlib_strided_smean(len, x, 1); + if (v != v) { + printf("should not return NaN\n"); break; } } + elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); + + if (v != v) { + printf("should not return NaN\n"); } + + free(x); // <<< free before returning return elapsed; } + /** * Main execution sequence. */ -int main( void ) { +int main(void) { double elapsed; int count; int iter; @@ -132,20 +142,20 @@ int main( void ) { int j; // Use the current time to seed the random number generator: - srand( time( NULL ) ); + srand(time(NULL)); print_version(); count = 0; - for ( i = MIN; i <= MAX; i++ ) { - len = pow( 10, i ); - iter = ITERATIONS / pow( 10, i-1 ); - for ( j = 0; j < REPEATS; j++ ) { + for (i = MIN; i <= MAX; i++) { + len = pow(10, i); + iter = ITERATIONS / pow(10, i - 1); + for (j = 0; j < REPEATS; j++) { count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); + printf("# c::%s:len=%d\n", NAME, len); + elapsed = benchmark(iter, len); + print_results(iter, elapsed); + printf("ok %d benchmark finished\n", count); } } - print_summary( count, count ); + print_summary(count, count); } diff --git a/tools/make/lib/lint/javascript/stdlib b/tools/make/lib/lint/javascript/stdlib new file mode 160000 index 000000000000..22bc1a64a6f2 --- /dev/null +++ b/tools/make/lib/lint/javascript/stdlib @@ -0,0 +1 @@ +Subproject commit 22bc1a64a6f26ca04f66f6a836711546d87edcac