Skip to content

Commit a832b06

Browse files
committed
Auto-generated commit
1 parent c505b2b commit a832b06

File tree

19 files changed

+90
-60
lines changed

19 files changed

+90
-60
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9095,6 +9095,7 @@ A total of 25 people contributed to this release. Thank you to the following con
90959095

90969096
<details>
90979097

9098+
- [`6187773`](https://github.com/stdlib-js/stdlib/commit/6187773d4d95c73e0e8a8f6c43dcd53d5323f9d2) - **bench:** update random value generation [(#6298)](https://github.com/stdlib-js/stdlib/pull/6298) _(by Harsh)_
90989099
- [`44445ab`](https://github.com/stdlib-js/stdlib/commit/44445ab0a65a29e3bb593a11f87d9035e552474f) - **bench:** update random value generation [(#6302)](https://github.com/stdlib-js/stdlib/pull/6302) _(by Harsh)_
90999100
- [`d3bf998`](https://github.com/stdlib-js/stdlib/commit/d3bf998980b55e4a0ad53ad3b9053c9b12204b0e) - **bench:** update random value generation [(#6269)](https://github.com/stdlib-js/stdlib/pull/6269) _(by Harsh, Athan Reines)_
91009101
- [`5b45d4b`](https://github.com/stdlib-js/stdlib/commit/5b45d4b48b3cff026b41a744f16ecc49d97af267) - **bench:** update random value generation [(#6288)](https://github.com/stdlib-js/stdlib/pull/6288) _(by Harsh)_

base/special/cos/benchmark/benchmark.js

+7-5
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( './../../../../base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var cos = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, -10.0, 10.0 );
38+
3739
b.tic();
3840
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*20.0 ) - 10.0;
40-
y = cos( x );
41+
y = cos( x[ i%x.length ] );
4142
if ( isnan( y ) ) {
4243
b.fail( 'should not return NaN' );
4344
}
@@ -55,10 +56,11 @@ bench( pkg+'::built-in', function benchmark( b ) {
5556
var y;
5657
var i;
5758

59+
x = uniform( 100, -10.0, 10.0 );
60+
5861
b.tic();
5962
for ( i = 0; i < b.iterations; i++ ) {
60-
x = ( randu()*20.0 ) - 10.0;
61-
y = Math.cos( x ); // eslint-disable-line stdlib/no-builtin-math
63+
y = Math.cos( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6264
if ( isnan( y ) ) {
6365
b.fail( 'should not return NaN' );
6466
}

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

base/special/cos/benchmark/c/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ static double rand_double( void ) {
9090
*/
9191
static double benchmark( void ) {
9292
double elapsed;
93-
double x;
93+
double x[ 100 ];
9494
double y;
9595
double t;
9696
int i;
9797

98+
for ( i = 0; i < 100; i++ ) {
99+
x[ i ] = ( 20.0*rand_double() ) - 10.0;
100+
}
101+
98102
t = tic();
99103
for ( i = 0; i < ITERATIONS; i++ ) {
100-
x = ( 20.0*rand_double() ) - 10.0;
101-
y = cos( x );
104+
y = cos( x[ i%100 ] );
102105
if ( y != y ) {
103106
printf( "should not return NaN\n" );
104107
break;

base/special/cos/benchmark/c/cephes/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,18 @@ static double rand_double( void ) {
9595
*/
9696
static double benchmark( void ) {
9797
double elapsed;
98-
double x;
98+
double x[ 100 ];
9999
double y;
100100
double t;
101101
int i;
102102

103+
for ( i = 0; i < 100; i++ ) {
104+
x[ i ] = ( 20.0*rand_double() ) - 10.0;
105+
}
106+
103107
t = tic();
104108
for ( i = 0; i < ITERATIONS; i++ ) {
105-
x = ( 20.0*rand_double() ) - 10.0;
106-
y = cos( x );
109+
y = cos( x[ i%100 ] );
107110
if ( y != y ) {
108111
printf( "should not return NaN\n" );
109112
break;

base/special/cos/benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

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

base/special/cos/test/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,18 @@ tape( 'the function computes the cosine (huge positive values)', function test(
199199

200200
tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) {
201201
var v = cos( NaN );
202-
t.equal( isnan( v ), true, 'returns NaN' );
202+
t.equal( isnan( v ), true, 'returns expected value' );
203203
t.end();
204204
});
205205

206206
tape( 'the function returns `NaN` if provided a `+infinity`', function test( t ) {
207207
var v = cos( PINF );
208-
t.equal( isnan( v ), true, 'returns NaN' );
208+
t.equal( isnan( v ), true, 'returns expected value' );
209209
t.end();
210210
});
211211

212212
tape( 'the function returns `NaN` if provided a `-infinity`', function test( t ) {
213213
var v = cos( NINF );
214-
t.equal( isnan( v ), true, 'returns NaN' );
214+
t.equal( isnan( v ), true, 'returns expected value' );
215215
t.end();
216216
});

base/special/cos/test/test.native.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,18 @@ tape( 'the function computes the cosine (huge positive values)', opts, function
208208

209209
tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) {
210210
var v = cos( NaN );
211-
t.equal( isnan( v ), true, 'returns NaN' );
211+
t.equal( isnan( v ), true, 'returns expected value' );
212212
t.end();
213213
});
214214

215215
tape( 'the function returns `NaN` if provided a `+infinity`', opts, function test( t ) {
216216
var v = cos( PINF );
217-
t.equal( isnan( v ), true, 'returns NaN' );
217+
t.equal( isnan( v ), true, 'returns expected value' );
218218
t.end();
219219
});
220220

221221
tape( 'the function returns `NaN` if provided a `-infinity`', opts, function test( t ) {
222222
var v = cos( NINF );
223-
t.equal( isnan( v ), true, 'returns NaN' );
223+
t.equal( isnan( v ), true, 'returns expected value' );
224224
t.end();
225225
});

base/special/cosd/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( './../../../../base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var cosd = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

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

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

base/special/cosd/benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

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

base/special/cosd/test/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ tape( 'main export is a function', function test( t ) {
4545

4646
tape( 'if provided a `NaN`, the function returns `NaN`', function test( t ) {
4747
var v = cosd( NaN );
48-
t.equal( isnan( v ), true, 'returns NaN' );
48+
t.equal( isnan( v ), true, 'returns expected value' );
4949
t.end();
5050
});
5151

@@ -99,13 +99,13 @@ tape( 'the function computes the cosine of an angle measured in degrees (positiv
9999

100100
tape( 'if provided `+infinity`, the function returns `NaN`', function test( t ) {
101101
var v = cosd( PINF );
102-
t.equal( isnan( v ), true, 'returns NaN' );
102+
t.equal( isnan( v ), true, 'returns expected value' );
103103
t.end();
104104
});
105105

106106
tape( 'if provided `-infinity`, the function returns `NaN`', function test( t ) {
107107
var v = cosd( NINF );
108-
t.equal( isnan( v ), true, 'returns NaN' );
108+
t.equal( isnan( v ), true, 'returns expected value' );
109109
t.end();
110110
});
111111

base/special/cosh/benchmark/benchmark.js

+7-5
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( './../../../../base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var cosh = require( './../lib' );
@@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
4141
var y;
4242
var i;
4343

44+
x = uniform( 100, -5.0, 5.0 );
45+
4446
b.tic();
4547
for ( i = 0; i < b.iterations; i++ ) {
46-
x = ( randu()*10.0 ) - 5.0;
47-
y = cosh( x );
48+
y = cosh( x[ i%x.length ] );
4849
if ( isnan( y ) ) {
4950
b.fail( 'should not return NaN' );
5051
}
@@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) {
6263
var y;
6364
var i;
6465

66+
x = uniform( 100, -5.0, 5.0 );
67+
6568
b.tic();
6669
for ( i = 0; i < b.iterations; i++ ) {
67-
x = ( randu()*10.0 ) - 5.0;
68-
y = Math.cosh( x ); // eslint-disable-line stdlib/no-builtin-math
70+
y = Math.cosh( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6971
if ( isnan( y ) ) {
7072
b.fail( 'should not return NaN' );
7173
}

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

base/special/cosh/benchmark/c/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ static double rand_double( void ) {
9090
*/
9191
static double benchmark( void ) {
9292
double elapsed;
93-
double x;
93+
double x[ 100 ];
9494
double y;
9595
double t;
9696
int i;
9797

98+
for ( i = 0; i < 100; i++ ) {
99+
x[ i ] = ( 10.0*rand_double() ) - 5.0;
100+
}
101+
98102
t = tic();
99103
for ( i = 0; i < ITERATIONS; i++ ) {
100-
x = ( 10.0*rand_double() ) - 5.0;
101-
y = cosh( x );
104+
y = cosh( x[ i%100 ] );
102105
if ( y != y ) {
103106
printf( "should not return NaN\n" );
104107
break;

base/special/cosh/benchmark/c/cephes/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,18 @@ static double rand_double( void ) {
9595
*/
9696
static double benchmark( void ) {
9797
double elapsed;
98-
double x;
98+
double x[ 100 ];
9999
double y;
100100
double t;
101101
int i;
102102

103+
for ( i = 0; i < 100; i++ ) {
104+
x[ i ] = ( 10.0*rand_double() ) - 5.0;
105+
}
106+
103107
t = tic();
104108
for ( i = 0; i < ITERATIONS; i++ ) {
105-
x = ( 10.0*rand_double() ) - 5.0;
106-
y = cosh( x );
109+
y = cosh( x[ i%100 ] );
107110
if ( y != y ) {
108111
printf( "should not return NaN\n" );
109112
break;

base/special/cosh/benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

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

0 commit comments

Comments
 (0)