Skip to content

Commit

Permalink
chore: update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjjoshi committed Aug 23, 2024
1 parent 80114cf commit 4abd001
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var acotdf = require( './../lib' );
Expand All @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 2.0 ) - 1.0;
y = acotdf( x );
y = acotdf( x[ i % x.length ] );
if ( isnanf( y ) ) {
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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 2.0 ) - 1.0;
y = acotdf( x );
y = acotdf( x[ i % x.length ] );
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ static float rand_float( void ) {
static double benchmark( void ) {
double elapsed;
double t;
float x;
float x[ 100 ];
float y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 2.0f * rand_float() ) - 1.0f;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 2.0f * rand_float() ) - 1.0f;
y = stdlib_base_acotdf( x );
y = stdlib_base_acotdf( x[ i % 100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down

0 comments on commit 4abd001

Please sign in to comment.