Skip to content

Commit 325ca07

Browse files
committed
bench: refactor benchmarks
1 parent c6fe24f commit 325ca07

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

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

37+
x = uniform( 10, 0.0, 10000.0, {
38+
'dtype': 'generic'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*10000.0 ) - 0.0;
40-
y = ln( x );
43+
y = ln( x[ i%x.length ] );
4144
if ( isnan( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}
@@ -55,10 +58,13 @@ bench( pkg+'::built-in', function benchmark( b ) {
5558
var y;
5659
var i;
5760

61+
x = uniform( 10, 0.0, 10000.0, {
62+
'dtype': 'generic'
63+
});
64+
5865
b.tic();
5966
for ( i = 0; i < b.iterations; i++ ) {
60-
x = ( randu()*10000.0 ) - 0.0;
61-
y = Math.log( x ); // eslint-disable-line stdlib/no-builtin-math
67+
y = Math.log( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6268
if ( isnan( y ) ) {
6369
b.fail( 'should not return NaN' );
6470
}

lib/node_modules/@stdlib/math/base/special/ln/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, 0.0, 10000.0, {
47+
'dtype': 'generic'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*10000.0 ) - 0.0;
49-
y = ln( x );
52+
y = ln( x[ i%x.length ] );
5053
if ( isnan( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

0 commit comments

Comments
 (0)