Skip to content

Commit e71eb03

Browse files
authored
bench: update random value generation
PR-URL: #6349 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 90b8cb0 commit e71eb03

File tree

20 files changed

+91
-66
lines changed

20 files changed

+91
-66
lines changed

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

Lines changed: 2 additions & 2 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/array/uniform' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var pkg = require( './../package.json' ).name;
@@ -36,7 +36,7 @@ bench( pkg, function benchmark( b ) {
3636
var z;
3737
var i;
3838

39-
x = randu( 100, -10.0, 10.0 );
39+
x = uniform( 100, -10.0, 10.0 );
4040
y = discreteUniform( 100, -1020.0, 1020.0 );
4141

4242
b.tic();

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

Lines changed: 2 additions & 2 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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2727
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -45,7 +45,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4545
var z;
4646
var i;
4747

48-
x = randu( 100, -10.0, 10.0 );
48+
x = uniform( 100, -10.0, 10.0 );
4949
y = discreteUniform( 100, -1020.0, 1020.0 );
5050

5151
b.tic();

lib/node_modules/@stdlib/math/base/special/lnf/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 lnf = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

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

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

Lines changed: 4 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,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, 0.0, 10000.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 10000.0 ) - 0.0;
49-
y = lnf( x );
50+
y = lnf( x[ i%x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

lib/node_modules/@stdlib/math/base/special/lnf/benchmark/c/native/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ static float rand_float( void ) {
9292
static double benchmark( void ) {
9393
double elapsed;
9494
double t;
95-
float x;
95+
float x[ 100 ];
9696
float y;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 10000.0f * rand_float() ) - 0.0f;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 10000.0f * rand_float() ) - 0.0f;
102-
y = stdlib_base_lnf( x );
105+
y = stdlib_base_lnf( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

lib/node_modules/@stdlib/math/base/special/lnf/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
225225
});
226226

227227
tape( 'the function returns `-infinity` if provided `0`', function test( t ) {
228-
t.equal( lnf( 0.0 ), NINF, 'equals -infinity' );
228+
t.equal( lnf( 0.0 ), NINF, 'returns expected value' );
229229
t.end();
230230
});
231231

232232
tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) {
233-
t.equal( lnf( PINF ), PINF, 'equals +infinity' );
233+
t.equal( lnf( PINF ), PINF, 'returns expected value' );
234234
t.end();
235235
});
236236

lib/node_modules/@stdlib/math/base/special/lnf/test/test.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
234234
});
235235

236236
tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) {
237-
t.equal( lnf( 0.0 ), NINF, 'equals -infinity' );
237+
t.equal( lnf( 0.0 ), NINF, 'returns expected value' );
238238
t.end();
239239
});
240240

241241
tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) {
242-
t.equal( lnf( PINF ), PINF, 'equals +infinity' );
242+
t.equal( lnf( PINF ), PINF, 'returns expected value' );
243243
t.end();
244244
});
245245

lib/node_modules/@stdlib/math/base/special/log1mexp/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 log1mexp = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

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

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

Lines changed: 4 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,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, 0.0, 1000.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*1000.0 ) - 0.0;
49-
y = log1mexp( x );
50+
y = log1mexp( x[ i%x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

lib/node_modules/@stdlib/math/base/special/log1mexp/benchmark/c/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,18 @@ double log1mexp( double x ) {
109109
*/
110110
static double benchmark( void ) {
111111
double elapsed;
112-
double x;
112+
double x[ 100 ];
113113
double y;
114114
double t;
115115
int i;
116116

117+
for ( i = 0; i < 100; i++ ) {
118+
x[ i ] = ( 1000.0*rand_double() ) - 0.0;
119+
}
120+
117121
t = tic();
118122
for ( i = 0; i < ITERATIONS; i++ ) {
119-
x = ( 1000.0*rand_double() ) - 0.0;
120-
y = log1mexp( x );
123+
y = log1mexp( x[ i%100 ] );
121124
if ( y != y ) {
122125
printf( "should not return NaN\n" );
123126
break;

0 commit comments

Comments
 (0)