Skip to content

Commit a851ddd

Browse files
authored
bench: refactor benchmarks and update function parameter description
PR-URL: #3907 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 3cd740e commit a851ddd

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

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

Lines changed: 3 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 randu = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var rempio2 = require( './../lib' );
@@ -36,11 +36,11 @@ bench( pkg, function benchmark( b ) {
3636
var i;
3737

3838
y = [ 0.0, 0.0 ];
39+
x = randu( 100, -100.0, 100.0 );
3940

4041
b.tic();
4142
for ( i = 0; i < b.iterations; i++ ) {
42-
x = ( randu()*200.0 ) - 100.0;
43-
n = rempio2( x, y );
43+
n = rempio2( x[ i % x.length ], y );
4444
if ( isnan( n ) ) {
4545
b.fail( 'should not return NaN' );
4646
}

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

Lines changed: 3 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 randu = 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;
@@ -45,11 +45,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4545
var i;
4646

4747
y = [ 0.0, 0.0 ];
48+
x = randu( 100, -100.0, 100.0 );
4849

4950
b.tic();
5051
for ( i = 0; i < b.iterations; i++ ) {
51-
x = ( randu() * 200.0 ) - 100.0;
52-
n = rempio2( x, y );
52+
n = rempio2( x[ i % x.length ], y );
5353
if ( isnan( n ) ) {
5454
b.fail( 'should not return NaN' );
5555
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,21 @@ static double rand_double( void ) {
9090
* @return elapsed time in seconds
9191
*/
9292
static double benchmark( void ) {
93+
double x[ 100 ];
9394
double elapsed;
9495
double rem1;
9596
double rem2;
96-
double x;
9797
double y;
9898
double t;
9999
int i;
100100

101+
for ( i = 0; i < 100; i++ ) {
102+
x[ i ] = ( rand_double() * 200.0 ) - 100.0;
103+
}
104+
101105
t = tic();
102106
for ( i = 0; i < ITERATIONS; i++ ) {
103-
x = ( rand_double() * 200.0 ) - 100.0;
104-
y = stdlib_base_rempio2( x, &rem1, &rem2 );
107+
y = stdlib_base_rempio2( x[ i % 100 ], &rem1, &rem2 );
105108
if ( y != y ) {
106109
printf( "should not return NaN\n" );
107110
break;

lib/node_modules/@stdlib/math/base/special/rempio2/src/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ static const double PIO2[] = {
227227
* - The hexadecimal values are the intended ones for the following constants. The decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the hexadecimal values shown.
228228
*
229229
* @param x input value
230-
* @param rem1 remainder element 1
231-
* @param rem2 remainder element 2
230+
* @param y output array to store the remainder
232231
* @param e0 the exponent of `x[0]` (must be <= 16360)
233232
* @param nx dimension of `x[]`
234233
* @return last 3 binary digits

0 commit comments

Comments
 (0)