Skip to content

Commit 78372e7

Browse files
author
aayush0325
committed
feat: updated benchmarks with pre-computation
1 parent 4159525 commit 78372e7

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bench( pkg, function benchmark( b ) {
4242

4343
b.tic();
4444
for ( i = 0; i < b.iterations; i++ ) {
45-
y = cabsf( values[ i%values.length ] );
45+
y = cabsf( values[ i % values.length ] );
4646
if ( isnanf( y ) ) {
4747
b.fail( 'should not return NaN' );
4848
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5151

5252
b.tic();
5353
for ( i = 0; i < b.iterations; i++ ) {
54-
y = cabsf( values[ i%values.length ] );
54+
y = cabsf( values[ i % values.length ] );
5555
if ( isnanf( y ) ) {
5656
b.fail( 'should not return NaN' );
5757
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,22 @@ static float rand_float( void ) {
9393
*/
9494
static double benchmark( void ) {
9595
double elapsed;
96-
float re;
97-
float im;
96+
float re[ 100 ];
97+
float im[ 100 ];
9898
float y;
9999
double t;
100100
int i;
101101

102+
for( i = 0; i < 100; i++ ){
103+
re[ i ] = ( 1000.0f * rand_float() ) - 500.0f;
104+
im[ i ] = ( 1000.0f * rand_float() ) - 500.0f;
105+
}
106+
102107
stdlib_complex64_t z;
103108

104109
t = tic();
105110
for ( i = 0; i < ITERATIONS; i++ ) {
106-
re = ( 1000.0f * rand_float() ) - 500.0f;
107-
im = ( 1000.0f * rand_float() ) - 500.0f;
108-
z = stdlib_complex64( re, im );
111+
z = stdlib_complex64( re[ i % 100 ], im[ i % 100 ] );
109112
y = stdlib_base_cabsf( z );
110113
if ( y != y ) {
111114
printf( "should not return NaN\n" );

0 commit comments

Comments
 (0)