diff --git a/lib/node_modules/@stdlib/stats/strided/dminsorted/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dminsorted/benchmark/c/benchmark.length.c deleted file mode 100644 index 2a1baaf2d489..000000000000 --- a/lib/node_modules/@stdlib/stats/strided/dminsorted/benchmark/c/benchmark.length.c +++ /dev/null @@ -1,197 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/stats/strided/dminsorted.h" -#include -#include -#include -#include -#include - -#define NAME "dminsorted" -#define ITERATIONS 1000000 -#define REPEATS 3 -#define MIN 1 -#define MAX 6 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @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" ); -} - -/** -* Prints benchmarks results. -* -* @param iterations number of iterations -* @param elapsed elapsed time in seconds -*/ -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" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark1( int iterations, int len ) { - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - x[ i ] = i; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dminsorted( 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" ); - } - return elapsed; -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark2( int iterations, int len ) { - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - x[ i ] = i; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dminsorted_ndarray( len, x, 1, 0 ); - if ( v != v ) { - printf( "should not return NaN\n" ); - break; - } - } - elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int count; - int iter; - int len; - int i; - int j; - - // Use the current time to seed the random number generator: - srand( time( NULL ) ); - - print_version(); - count = 0; - for ( i = MIN; i <= MAX; i++ ) { - len = pow( 10, i ); - iter = ITERATIONS; - for ( j = 0; j < REPEATS; j++ ) { - count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark1( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - 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:ndarray:len=%d\n", NAME, len ); - elapsed = benchmark2( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - print_summary( count, count ); -} diff --git a/lib/node_modules/@stdlib/stats/strided/dmskmax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dmskmax/benchmark/c/benchmark.length.c deleted file mode 100644 index eb429c94db8b..000000000000 --- a/lib/node_modules/@stdlib/stats/strided/dmskmax/benchmark/c/benchmark.length.c +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/stats/strided/dmskmax.h" -#include -#include -#include -#include -#include - -#define NAME "dmskmax" -#define ITERATIONS 1000000 -#define REPEATS 3 -#define MIN 1 -#define MAX 6 - -/** -* Prints the TAP version. -*/ -static void print_version( void ) { - printf( "TAP version 13\n" ); -} - -/** -* Prints the TAP summary. -* -* @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" ); -} - -/** -* Prints benchmarks results. -* -* @param iterations number of iterations -* @param elapsed elapsed time in seconds -*/ -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" ); -} - -/** -* Returns a clock time. -* -* @return clock time -*/ -static double tic( void ) { - struct timeval now; - gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; -} - -/** -* Generates a random number on the interval [0,1). -* -* @return random number -*/ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - if ( rand_double() < 0.2 ) { - mask[ i ] = 1; // missing - } else { - mask[ i ] = 0; - } - x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dmskmax( len, x, 1, mask, 1 ); - if ( v != v ) { - printf( "should not return NaN\n" ); - break; - } - } - elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); - } - return elapsed; -} - -/** -* Runs a benchmark. -* -* @param iterations number of iterations -* @param len array length -* @return elapsed time in seconds -*/ -static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; - double elapsed; - double x[ len ]; - double v; - double t; - int i; - - for ( i = 0; i < len; i++ ) { - if ( rand_double() < 0.2 ) { - mask[ i ] = 1; // missing - } else { - mask[ i ] = 0; - } - x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; - } - v = 0.0; - t = tic(); - for ( i = 0; i < iterations; i++ ) { - // cppcheck-suppress uninitvar - v = stdlib_strided_dmskmax_ndarray( len, x, 1, 0, mask, 1, 0 ); - if ( v != v ) { - printf( "should not return NaN\n" ); - break; - } - } - elapsed = tic() - t; - if ( v != v ) { - printf( "should not return NaN\n" ); - } - return elapsed; -} - -/** -* Main execution sequence. -*/ -int main( void ) { - double elapsed; - int count; - int iter; - int len; - int i; - int j; - - // Use the current time to seed the random number generator: - 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++ ) { - count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark1( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - 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:ndarray:len=%d\n", NAME, len ); - elapsed = benchmark2( iter, len ); - print_results( iter, elapsed ); - printf( "ok %d benchmark finished\n", count ); - } - } - print_summary( count, count ); -} diff --git a/lib/node_modules/@stdlib/stats/strided/dmskmin/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dmskmin/benchmark/c/benchmark.length.c index c60b2076ee7f..db42e4e7522a 100644 --- a/lib/node_modules/@stdlib/stats/strided/dmskmin/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/dmskmin/benchmark/c/benchmark.length.c @@ -97,11 +97,12 @@ static double rand_double( void ) { static double benchmark1( int iterations, int len ) { unsigned char mask[ len ]; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -124,6 +125,7 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -137,11 +139,12 @@ static double benchmark1( int iterations, int len ) { static double benchmark2( int iterations, int len ) { unsigned char mask[ len ]; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *) malloc( len * sizeof( double ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -164,6 +167,7 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; }