Skip to content

bench: refactor benchmarks and update function parameter description #3907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var rempio2 = require( './../lib' );
Expand All @@ -36,11 +36,11 @@ bench( pkg, function benchmark( b ) {
var i;

y = [ 0.0, 0.0 ];
x = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*200.0 ) - 100.0;
n = rempio2( x, y );
n = rempio2( x[ i % x.length ], y );
if ( isnan( n ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -45,11 +45,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var i;

y = [ 0.0, 0.0 ];
x = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 200.0 ) - 100.0;
n = rempio2( x, y );
n = rempio2( x[ i % x.length ], y );
if ( isnan( n ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double elapsed;
double rem1;
double rem2;
double x;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( rand_double() * 200.0 ) - 100.0;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( rand_double() * 200.0 ) - 100.0;
y = stdlib_base_rempio2( x, &rem1, &rem2 );
y = stdlib_base_rempio2( x[ i % 100 ], &rem1, &rem2 );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ static const double PIO2[] = {
* - 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.
*
* @param x input value
* @param rem1 remainder element 1
* @param rem2 remainder element 2
* @param y output array to store the remainder
* @param e0 the exponent of `x[0]` (must be <= 16360)
* @param nx dimension of `x[]`
* @return last 3 binary digits
Expand Down
Loading