Skip to content

Commit ad7a467

Browse files
committed
bench: refactor value generation
1 parent aa5d241 commit ad7a467

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/node_modules/@stdlib/math/base/tools/normhermitepoly/benchmark/benchmark.factory.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var pkg = require( './../package.json' ).name;
2828
var factory = require( './../lib/factory.js' );
@@ -35,10 +35,11 @@ bench( pkg+'::create:factory', function benchmark( b ) {
3535
var f;
3636
var i;
3737

38+
n = discreteUniform( 10, 1, 10 );
39+
3840
b.tic();
3941
for ( i = 0; i < b.iterations; i++ ) {
40-
n = discreteUniform( 1, 10 );
41-
f = factory( n );
42+
f = factory( n[ i%n.length ] );
4243
if ( typeof f !== 'function' ) {
4344
b.fail( 'should return a function' );
4445
}
@@ -58,11 +59,11 @@ bench( pkg+'::evaluate:factory', function benchmark( b ) {
5859
var i;
5960

6061
f = factory( 2 );
62+
x = uniform( 10, -5.0, 5.0 );
6163

6264
b.tic();
6365
for ( i = 0; i < b.iterations; i++ ) {
64-
x = ( randu()*10.0 ) - 5.0;
65-
v = f( x );
66+
v = f( x[ i%x.length ] );
6667
if ( isnan( v ) ) {
6768
b.fail( 'should not return NaN' );
6869
}

lib/node_modules/@stdlib/math/base/tools/normhermitepoly/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var normhermitepoly = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 10, -5.0, 5.0 );
38+
3739
b.tic();
3840
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*10.0 ) - 5.0;
40-
y = normhermitepoly( 2, x );
41+
y = normhermitepoly( 2, x[ i%x.length ] );
4142
if ( isnan( y ) ) {
4243
b.fail( 'should not return NaN' );
4344
}

0 commit comments

Comments
 (0)