Skip to content

Commit de545e8

Browse files
bench: add opts and use string interpolation in stats/base/dists/halfnormal/mode
PR-URL: #9904 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 56a8646 commit de545e8

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/benchmark/benchmark.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ var mode = require( './../lib' );
3232

3333
bench( pkg, function benchmark( b ) {
3434
var sigma;
35-
var len;
35+
var opts;
3636
var y;
3737
var i;
3838

39-
len = 100;
40-
sigma = uniform( len, EPS, 20.0 );
39+
opts = {
40+
'dtype': 'float64'
41+
};
42+
sigma = uniform( 100, EPS, 20.0, opts );
4143

4244
b.tic();
4345
for ( i = 0; i < b.iterations; i++ ) {
44-
y = mode( sigma[ i % len ] );
46+
y = mode( sigma[ i%sigma.length ] );
4547
if ( isnan( y ) ) {
4648
b.fail( 'should not return NaN' );
4749
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/benchmark/benchmark.native.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var bench = require( '@stdlib/bench' );
2525
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' );
28+
var format = require( '@stdlib/string/format' );
2829
var EPS = require( '@stdlib/constants/float64/eps' );
2930
var pkg = require( './../package.json' ).name;
3031

@@ -39,18 +40,20 @@ var opts = {
3940

4041
// MAIN //
4142

42-
bench( pkg+'::native', opts, function benchmark( b ) {
43+
bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
4344
var sigma;
44-
var len;
45+
var opts;
4546
var y;
4647
var i;
4748

48-
len = 100;
49-
sigma = uniform( len, EPS, 20.0 );
49+
opts = {
50+
'dtype': 'float64'
51+
};
52+
sigma = uniform( 100, EPS, 20.0, opts );
5053

5154
b.tic();
5255
for ( i = 0; i < b.iterations; i++ ) {
53-
y = mode( sigma[ i % len ] );
56+
y = mode( sigma[ i%sigma.length ] );
5457
if ( isnan( y ) ) {
5558
b.fail( 'should not return NaN' );
5659
}

0 commit comments

Comments
 (0)