Skip to content

Commit 69c1704

Browse files
bench: update random value generation
PR-URL: #5369 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 4340425 commit 69c1704

File tree

21 files changed

+100
-67
lines changed

21 files changed

+100
-67
lines changed

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

+4-3
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 acsc = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

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

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

+4-3
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 i;
4444
var x;
4545

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

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,19 @@ static double rand_double( void ) {
9090
* @return elapsed time in seconds
9191
*/
9292
static double benchmark( void ) {
93+
double x[ 100 ];
9394
double elapsed;
94-
double x;
9595
double y;
9696
double t;
9797
int i;
9898

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

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ tape( 'the function computes the arccosecant (positive values)', function test(
9292

9393
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
9494
var v = acsc( NaN );
95-
t.equal( isnan( v ), true, 'returns NaN' );
95+
t.equal( isnan( v ), true, 'returns expected value' );
9696
t.end();
9797
});
9898

@@ -103,7 +103,7 @@ tape( 'the function returns `NaN` if provided a nonpositive value greater than `
103103
for ( i = 0; i < 1e3; i++ ) {
104104
v = -randu();
105105
if ( v > -1.0 ) {
106-
t.equal( isnan( acsc( v ) ), true, 'returns NaN when provided '+v );
106+
t.equal( isnan( acsc( v ) ), true, 'returns expected value when provided '+v );
107107
}
108108
}
109109
t.end();
@@ -116,7 +116,7 @@ tape( 'the function returns `NaN` if provided a nonnegative value less than `+1`
116116
for ( i = 0; i < 1e3; i++ ) {
117117
v = randu();
118118
if ( v < 1.0 ) {
119-
t.equal( isnan( acsc( v ) ), true, 'returns NaN when provided '+v );
119+
t.equal( isnan( acsc( v ) ), true, 'returns expected value when provided '+v );
120120
}
121121
}
122122
t.end();

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ tape( 'the function computes the arccosecant (positive values)', opts, function
101101

102102
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
103103
var v = acsc( NaN );
104-
t.equal( isnan( v ), true, 'returns NaN' );
104+
t.equal( isnan( v ), true, 'returns expected value' );
105105
t.end();
106106
});
107107

@@ -112,7 +112,7 @@ tape( 'the function returns `NaN` if provided a nonpositive value greater than `
112112
for ( i = 0; i < 1e3; i++ ) {
113113
v = -randu();
114114
if ( v > -1.0 ) {
115-
t.equal( isnan( acsc( v ) ), true, 'returns NaN when provided '+v );
115+
t.equal( isnan( acsc( v ) ), true, 'returns expected value when provided '+v );
116116
}
117117
}
118118
t.end();
@@ -125,7 +125,7 @@ tape( 'the function returns `NaN` if provided a nonnegative value less than `+1`
125125
for ( i = 0; i < 1e3; i++ ) {
126126
v = randu();
127127
if ( v < 1.0 ) {
128-
t.equal( isnan( acsc( v ) ), true, 'returns NaN when provided '+v );
128+
t.equal( isnan( acsc( v ) ), true, 'returns expected value when provided '+v );
129129
}
130130
}
131131
t.end();

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

+4-3
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 acscd = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

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

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

+4-3
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, 1.0, 3.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 2.0 ) + 1.0;
49-
y = acscd( x );
50+
y = acscd( x[ i % x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,19 @@ static double rand_double( void ) {
9090
* @return elapsed time in seconds
9191
*/
9292
static double benchmark( void ) {
93+
double x[ 100 ];
9394
double elapsed;
94-
double x;
9595
double y;
9696
double t;
9797
int i;
9898

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

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ tape( 'the function computes the arccosecant in degrees (positive values)', func
9292

9393
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
9494
var v = acscd( NaN );
95-
t.equal( isnan( v ), true, 'returns NaN' );
95+
t.equal( isnan( v ), true, 'returns expected value' );
9696
t.end();
9797
});
9898

@@ -102,7 +102,7 @@ tape( 'the function returns `NaN` if provided a value greater than `-1`', functi
102102

103103
for ( i = 0; i < 1e3; i++ ) {
104104
v = -randu() - EPS;
105-
t.equal( isnan( acscd( v ) ), true, 'returns NaN when provided '+v );
105+
t.equal( isnan( acscd( v ) ), true, 'returns expected value when provided '+v );
106106
}
107107
t.end();
108108
});
@@ -113,7 +113,7 @@ tape( 'the function returns `NaN` if provided a value less than `+1`', function
113113

114114
for ( i = 0; i < 1e3; i++ ) {
115115
v = (randu()) + EPS;
116-
t.equal( isnan( acscd( v ) ), true, 'returns NaN when provided '+v );
116+
t.equal( isnan( acscd( v ) ), true, 'returns expected value when provided '+v );
117117
}
118118
t.end();
119119
});

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ tape( 'the function computes the arccosecant in degrees (positive values)', opts
101101

102102
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
103103
var v = acscd( NaN );
104-
t.equal( isnan( v ), true, 'returns NaN' );
104+
t.equal( isnan( v ), true, 'returns expected value' );
105105
t.end();
106106
});
107107

@@ -111,7 +111,7 @@ tape( 'the function returns `NaN` if provided a value greater than `-1`', opts,
111111

112112
for ( i = 0; i < 1e3; i++ ) {
113113
v = -randu() - EPS;
114-
t.equal( isnan( acscd( v ) ), true, 'returns NaN when provided '+v );
114+
t.equal( isnan( acscd( v ) ), true, 'returns expected value when provided '+v );
115115
}
116116
t.end();
117117
});
@@ -122,7 +122,7 @@ tape( 'the function returns `NaN` if provided a value less than `+1`', opts, fun
122122

123123
for ( i = 0; i < 1e3; i++ ) {
124124
v = (randu()) + EPS;
125-
t.equal( isnan( acscd( v ) ), true, 'returns NaN when provided '+v );
125+
t.equal( isnan( acscd( v ) ), true, 'returns expected value when provided '+v );
126126
}
127127
t.end();
128128
});

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

+6-3
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var acscdf = require( './../lib' );
@@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, 1.0, 3.0, {
38+
'dtype': 'float32'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu() * 2.0 ) + 1.0;
40-
y = acscdf( x );
43+
y = acscdf( x[ i % x.length ] );
4144
if ( isnanf( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}

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

+6-3
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
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( 100, 1.0, 3.0, {
47+
'dtype': 'float32'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 2.0 ) + 1.0;
49-
y = acscdf( x );
52+
y = acscdf( x[ i % x.length ] );
5053
if ( isnanf( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

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

+6-3
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 ] = ( 2.0f * rand_float() ) + 1.0f;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 2.0f * rand_float() ) + 1.0f;
102-
y = stdlib_base_acscdf( x );
105+
y = stdlib_base_acscdf( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

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

+6-3
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var acscf = require( './../lib' );
@@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, 1.0, 3.0, {
38+
'dtype': 'float32'
39+
});
40+
3741
b.tic();
3842
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu() * 2.0 ) + 1.0;
40-
y = acscf( x );
43+
y = acscf( x[ i % x.length ] );
4144
if ( isnanf( y ) ) {
4245
b.fail( 'should not return NaN' );
4346
}

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

+6-3
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
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( 100, 1.0, 3.0, {
47+
'dtype': 'float32'
48+
});
49+
4650
b.tic();
4751
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 2.0 ) + 1.0;
49-
y = acscf( x );
52+
y = acscf( x[ i % x.length ] );
5053
if ( isnanf( y ) ) {
5154
b.fail( 'should not return NaN' );
5255
}

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

+6-3
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 ] = ( 2.0f * rand_float() ) + 1.0f;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 2.0f * rand_float() ) + 1.0f;
102-
y = stdlib_base_acscf( x );
105+
y = stdlib_base_acscf( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

0 commit comments

Comments
 (0)