From 38eddbf3d742ebbed96e2df0850eb09c5381d29a Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Fri, 17 Apr 2026 03:21:22 +0600 Subject: [PATCH 1/2] bench: refactor random number generation in `number/int32/base/mul` --- .../int32/base/mul/benchmark/benchmark.js | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js index 71dd50ce207e..59b5aeb87b6a 100644 --- a/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var minstd = require( '@stdlib/random/base/minstd' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var pkg = require( './../package.json' ).name; var imul = require( './../lib' ); var polyfill = require( './../lib/polyfill.js' ); @@ -35,17 +34,20 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = discreteUniform( 100, 0, 10, { + 'dtype': 'int32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = minstd(); - y = imul( x|0, x|0 ); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + y = imul( x[ i%x.length ], 10 ); + if ( y > 100 ) { + b.fail( 'unexpected result' ); } } b.toc(); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + if ( y > 100 ) { + b.fail( 'unexpected result' ); } b.pass( 'benchmark finished' ); b.end(); @@ -56,38 +58,44 @@ bench( pkg+'::polyfill', function benchmark( b ) { var y; var i; + x = discreteUniform( 100, 0, 10, { + 'dtype': 'int32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = minstd(); - y = polyfill( x|0, x|0 ); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + y = polyfill( x[ i%x.length ], 10 ); + if ( y > 100 ) { + b.fail( 'unexpected result' ); } } b.toc(); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + if ( y > 100 ) { + b.fail( 'unexpected result' ); } b.pass( 'benchmark finished' ); b.end(); }); -bench( pkg+'::naive_multiplication', function benchmark( b ) { +bench( pkg+'::inline', function benchmark( b ) { var x; var y; var i; + x = discreteUniform( 100, 0, 10, { + 'dtype': 'int32' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = minstd(); - y = ( x|0 ) * ( x|0 ); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + y = ( ( x[ i%x.length ] ) * 5 ) | 0; + if ( y > 100 ) { + b.fail( 'unexpected result' ); } } b.toc(); - if ( isnan( y ) ) { - b.fail( 'should not return NaN' ); + if ( y > 100 ) { + b.fail( 'unexpected result' ); } b.pass( 'benchmark finished' ); b.end(); From 698f6d318f5d3031835440d5f46dcda2ee068441 Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Fri, 17 Apr 2026 03:33:15 +0600 Subject: [PATCH 2/2] bench: refactor to use string interpolation in `number/int32/base/mul` --- .../@stdlib/number/int32/base/mul/benchmark/benchmark.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js index 59b5aeb87b6a..23d55712f3d3 100644 --- a/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/number/int32/base/mul/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var imul = require( './../lib' ); var polyfill = require( './../lib/polyfill.js' ); @@ -53,7 +54,7 @@ bench( pkg, function benchmark( b ) { b.end(); }); -bench( pkg+'::polyfill', function benchmark( b ) { +bench( format( '%s::polyfill', pkg ), function benchmark( b ) { var x; var y; var i; @@ -77,7 +78,7 @@ bench( pkg+'::polyfill', function benchmark( b ) { b.end(); }); -bench( pkg+'::inline', function benchmark( b ) { +bench( format( '%s::inline', pkg ), function benchmark( b ) { var x; var y; var i;