Skip to content

Commit cd95771

Browse files
bench: update random value generation
PR-URL: #5337 Reviewed-by: Athan Reines <[email protected]>
1 parent df0b96c commit cd95771

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

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

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

lib/node_modules/@stdlib/math/base/special/acotd/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, -1.0, 1.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 2.0 ) - 1.0;
49-
y = acotd( x );
50+
y = acotd( x[ i % x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

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

Lines changed: 6 additions & 3 deletions
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_acotd( x );
105+
y = stdlib_base_acotd( x[ i % 100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ tape( 'the function computes the arccotangent in degrees (positive values)', fun
9191

9292
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
9393
var v = acotd( NaN );
94-
t.equal( isnan( v ), true, 'returns NaN' );
94+
t.equal( isnan( v ), true, 'returns expected value' );
9595
t.end();
9696
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ tape( 'the function computes the arccotangent in degrees (positive values)', opt
100100

101101
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
102102
var v = acotd( NaN );
103-
t.equal( isnan( v ), true, 'returns NaN' );
103+
t.equal( isnan( v ), true, 'returns expected value' );
104104
t.end();
105105
});

0 commit comments

Comments
 (0)