Skip to content

Commit 53c6e6c

Browse files
hrshyakgryte
andauthored
bench: update random value generation
PR-URL: #9891 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 225a1d9 commit 53c6e6c

29 files changed

Lines changed: 411 additions & 358 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/normal/cdf/benchmark/benchmark.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
27+
var format = require( '@stdlib/string/format' );
2728
var pkg = require( './../package.json' ).name;
2829
var cdf = require( './../lib' );
2930

@@ -32,20 +33,22 @@ var cdf = require( './../lib' );
3233

3334
bench( pkg, function benchmark( b ) {
3435
var sigma;
35-
var len;
36+
var opts;
3637
var mu;
3738
var x;
3839
var y;
3940
var i;
4041

41-
len = 100;
42-
x = uniform( len, -100.0, 100.0 );
43-
mu = uniform( len, -50.0, 50.0 );
44-
sigma = uniform( len, EPS, 20.0 + EPS );
42+
opts = {
43+
'dtype': 'float64'
44+
};
45+
x = uniform( 100, -100.0, 100.0, opts );
46+
mu = uniform( 100, -50.0, 50.0, opts );
47+
sigma = uniform( 100, EPS, 20.0 + EPS, opts );
4548

4649
b.tic();
4750
for ( i = 0; i < b.iterations; i++ ) {
48-
y = cdf( x[ i % len ], mu[ i % len ], sigma[ i % len ]);
51+
y = cdf( x[ i % x.length ], mu[ i % mu.length ], sigma[ i % sigma.length ] );
4952
if ( isnan( y ) ) {
5053
b.fail( 'should not return NaN' );
5154
}
@@ -58,7 +61,7 @@ bench( pkg, function benchmark( b ) {
5861
b.end();
5962
});
6063

61-
bench( pkg+':factory', function benchmark( b ) {
64+
bench( format( '%s::factory', pkg ), function benchmark( b ) {
6265
var mycdf;
6366
var sigma;
6467
var mu;
@@ -69,7 +72,9 @@ bench( pkg+':factory', function benchmark( b ) {
6972
mu = 0.0;
7073
sigma = 1.5;
7174
mycdf = cdf.factory( mu, sigma );
72-
x = uniform( 100, -3.0, 3.0 );
75+
x = uniform( 100, -3.0, 3.0, {
76+
'dtype': 'float64'
77+
});
7378

7479
b.tic();
7580
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/normal/cdf/benchmark/benchmark.native.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ var opts = {
4141

4242
bench( pkg, opts, function benchmark( b ) {
4343
var sigma;
44-
var len;
44+
var opts;
4545
var mu;
4646
var x;
4747
var y;
4848
var i;
4949

50-
len = 100;
51-
x = uniform( len, -100.0, 100.0 );
52-
mu = uniform( len, -50.0, 50.0 );
53-
sigma = uniform( len, EPS, 20.0 + EPS );
50+
opts = {
51+
'dtype': 'float64'
52+
};
53+
x = uniform( 100, -100.0, 100.0, opts );
54+
mu = uniform( 100, -50.0, 50.0, opts );
55+
sigma = uniform( 100, EPS, 20.0 + EPS, opts );
5456

5557
b.tic();
5658
for ( i = 0; i < b.iterations; i++ ) {
57-
y = cdf( x[ i % len ], mu[ i % len ], sigma[ i % len ]);
59+
y = cdf( x[ i % x.length ], mu[ i % mu.length ], sigma[ i % sigma.length ] );
5860
if ( isnan( y ) ) {
5961
b.fail( 'should not return NaN' );
6062
}

0 commit comments

Comments
 (0)