Skip to content
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

bench: refactor random value generation #5465

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -34,7 +34,7 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = discreteUniform( 100, 0.0, 79.0 );
x = discreteUniform( 100, 0, 79 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = discreteUniform( 100, 0.0, 79.0 );
x = discreteUniform( 100, 0, 79 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static double benchmark( void ) {

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_binet( x[ i % 100 ] );
y = stdlib_base_binet( x[ i%100 ] );
if ( y < 0 ) {
printf( "should return a nonnegative number\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static double benchmark( void ) {

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_binet( x[ i % 100 ] );
y = stdlib_base_binet( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

tape( 'if provided `NaN`, the function returns `NaN`', function test( t ) {
var v = binet( NaN );
t.strictEqual( isnan( v ), true, 'returns expected value when provided a NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});

Expand Down Expand Up @@ -77,7 +77,7 @@
t.end();
});

tape( 'for nonpositive integers, the function approximates the nth negaFibonacci number', function test( t ) {

Check warning on line 80 in lib/node_modules/@stdlib/math/base/special/binet/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "nega"
var expected;
var delta;
var tol;
Expand All @@ -87,7 +87,7 @@
v = binet( i );
expected = negaFibonacci( i );
if ( v === expected ) {
t.strictEqual( v, expected, 'returns the '+i+'th negaFibonacci number' );

Check warning on line 90 in lib/node_modules/@stdlib/math/base/special/binet/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "nega"
} else {
delta = abs( v - expected );
tol = 12.0 * EPS * abs( expected );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ bench( pkg, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 1.0, 11.0 );
y = uniform( x.length, 1.0, 11.0 );
x = uniform( 100, 1, 11 );
y = uniform( 100, 1, 11 );
Comment on lines +38 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x = uniform( 100, 1, 11 );
y = uniform( 100, 1, 11 );
x = uniform( 100, 1.0, 11.0 );
y = uniform( 100, 1.0, 11.0 );


b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox( x[ j ], y[ j ] );
r = boxcox( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 1.0, 11.0 );
y = uniform( x.length, 1.0, 11.0 );
x = uniform( 100, 1, 11 );
y = uniform( 100, 1, 11 );
Comment on lines +47 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment


b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox( x[ j ], y[ j ] );
r = boxcox( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ bench( pkg, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox1p( x[ j ], y[ j ] );
r = boxcox1p( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox1p( x[ j ], y[ j ] );
r = boxcox1p( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ static double benchmark( void ) {
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( rand_double() * 10.0 );
y[ i ] = ( rand_double() * 10.0 );
x[ i ] = rand_double() * 10.0;
y[ i ] = rand_double() * 10.0;
}

t = tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ bench( pkg, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox1pinv( x[ j ], y[ j ]);
r = boxcox1pinv( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcox1pinv( x[ j ], y[ j ]);
r = boxcox1pinv( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ static double benchmark( void ) {
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( rand_double() * 10.0 );
y[ i ] = ( rand_double() * 10.0 );
x[ i ] = rand_double() * 10.0;
y[ i ] = rand_double() * 10.0;
}

t = tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ bench( pkg, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected throughout the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I don't understand when should I put .0 and when not It will be help full for me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I read it .

y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcoxinv( x[ j ], y[ j ] );
r = boxcoxinv( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var r;
var i;
var j;

x = uniform( 100, 0.0, 10.0 );
y = uniform( x.length, 0.0, 10.0 );
x = uniform( 100, 0, 10 );
y = uniform( 100, 0, 10 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % x.length;
r = boxcoxinv( x[ j ], y[ j ] );
r = boxcoxinv( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( r ) ) {
b.fail( 'should not return NaN' );
}
Expand Down