Skip to content

Commit

Permalink
bench: fix memory leak and use double-precision utility
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Sep 16, 2024
1 parent c7c8ce4 commit 5173030
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
Expand Down Expand Up @@ -70,12 +70,12 @@ function createBenchmark( len ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
zfill( x.length, z, x, 1 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
Expand Down Expand Up @@ -75,12 +75,12 @@ function createBenchmark( len ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
zfill( x.length, z, x, 1 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
Expand Down Expand Up @@ -70,12 +70,12 @@ function createBenchmark( len ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
zfill( x.length, z, x, 1, 0 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
Expand Down Expand Up @@ -75,12 +75,12 @@ function createBenchmark( len ) {
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
zfill( x.length, z, x, 1, 0 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
if ( isnan( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ static double rand_double( void ) {
*/
static double benchmark( int iterations, int len ) {
stdlib_complex128_t alpha;
double *x;
double elapsed;
double *x;
double t;
int i;

x = (double *)malloc( len*2 * sizeof( double ) );
x = (double *)malloc( len * 2 * sizeof( double ) );
alpha = stdlib_complex128( 1.0, 0.0 );
for ( i = 0; i < len*2; i+=2 ) {
x[ i ] = ( rand_double()*2.0 ) - 1.0;
Expand All @@ -120,6 +120,7 @@ static double benchmark( int iterations, int len ) {
if ( x[ 0 ] != x[ 0 ] ) {
printf( "should not return NaN\n" );
}
free( x );
return elapsed;
}

Expand Down

0 comments on commit 5173030

Please sign in to comment.