Skip to content

Commit c6fe24f

Browse files
committed
bench: refactor benchmarks
1 parent 923a355 commit c6fe24f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

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

Lines changed: 6 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 exp2 = require( './../lib' );
@@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 10, -1022.0, 1022.0, {
38+
'dtype': 'generic'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*2044.0 ) - 1022.0;
40-
y = exp2( x );
43+
y = exp2( x[ i%x.length ] );
4144
if ( isnan( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,10 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 10, -1022.0, 1022.0, {
47+
'dtype': 'generic'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 2044.0 ) - 1022.0;
49-
y = exp2( x );
52+
y = exp2( x[ i%x.length ] );
5053
if ( isnan( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

0 commit comments

Comments
 (0)