Skip to content

Commit 1605261

Browse files
committed
feat: updated benchmarks with precomputation
1 parent 4b71efe commit 1605261

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var round = require( '@stdlib/math/base/special/round' );
24+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2625
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2726
var pkg = require( './../package.json' ).name;
2827
var lcmf = require( './../lib' );
@@ -36,11 +35,12 @@ bench( pkg, function benchmark( b ) {
3635
var z;
3736
var i;
3837

38+
x = discreteUniform( 100, 1.0, 100.0 );
39+
y = discreteUniform( 100, 1.0, 100.0 );
40+
3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {
41-
x = round( randu() * 50.0 );
42-
y = round( randu() * 50.0 );
43-
z = lcmf( x, y );
43+
z = lcmf( x[ i%x.length ], y[ i%y.length ] );
4444
if ( isnanf( z ) ) {
4545
b.fail( 'should not return NaN' );
4646
}

lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var round = require( '@stdlib/math/base/special/round' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2726
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
2928
var pkg = require( './../package.json' ).name;
@@ -45,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4544
var z;
4645
var i;
4746

47+
x = discreteUniform( 100, 1.0, 100.0 );
48+
y = discreteUniform( 100, 1.0, 100.0 );
49+
4850
b.tic();
4951
for ( i = 0; i < b.iterations; i++ ) {
50-
x = round( randu() * 50.0 );
51-
y = round( randu() * 50.0 );
52-
z = lcmf( x, y );
52+
z = lcmf( x[ i%x.length ], y[ i%y.length ] );
5353
if ( isnanf( z ) ) {
5454
b.fail( 'should not return NaN' );
5555
}

0 commit comments

Comments
 (0)