From 8c7c64b4abf9bb5fa1f6b999f5448c65d86b0583 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Wed, 19 Feb 2025 22:13:46 -0800 Subject: [PATCH] refactor: benchmarks and test messages --- 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: passed - task: lint_javascript_benchmarks status: passed - 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: missing_dependencies - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../math/base/special/acotd/benchmark/benchmark.js | 7 ++++--- .../base/special/acotd/benchmark/benchmark.native.js | 7 ++++--- .../base/special/acotd/benchmark/c/native/benchmark.c | 9 ++++++--- .../@stdlib/math/base/special/acotd/test/test.js | 2 +- .../@stdlib/math/base/special/acotd/test/test.native.js | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.js index d95b44364b73..05594dc2e954 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var acotd = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 100, -1.0, 1.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*2.0 ) - 1.0; - y = acotd( x ); + y = acotd( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.native.js index d6fd4c9208fc..eb556465efdd 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 100, -1.0, 1.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 2.0 ) - 1.0; - y = acotd( x ); + y = acotd( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/c/native/benchmark.c index 63403b9c9a16..5da93c73ca13 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/acotd/benchmark/c/native/benchmark.c @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 2.0 * rand_double() ) - 1.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 2.0 * rand_double() ) - 1.0; - y = stdlib_base_acotd( x ); + y = stdlib_base_acotd( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/acotd/test/test.js b/lib/node_modules/@stdlib/math/base/special/acotd/test/test.js index df584aab274d..9d792e626171 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotd/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acotd/test/test.js @@ -91,6 +91,6 @@ tape( 'the function computes the arccotangent in degrees (positive values)', fun tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v = acotd( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/acotd/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acotd/test/test.native.js index 94569d5226de..4450f192ebc1 100644 --- a/lib/node_modules/@stdlib/math/base/special/acotd/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acotd/test/test.native.js @@ -100,6 +100,6 @@ tape( 'the function computes the arccotangent in degrees (positive values)', opt tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = acotd( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); });