Skip to content

Commit 5f09d06

Browse files
authored
bench: update cpp benchmarks
Signed-off-by: Gunj Joshi <[email protected]>
1 parent 5d794cb commit 5f09d06

File tree

1 file changed

+8
-5
lines changed
  • lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp

1 file changed

+8
-5
lines changed

lib/node_modules/@stdlib/math/base/special/ldexp/benchmark/cpp/benchmark.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,20 @@ double rand_double() {
9393
*/
9494
double benchmark() {
9595
double elapsed;
96-
double x;
97-
double y;
96+
double x[ 100 ];
97+
double y[ 100 ];
9898
double z;
9999
double t;
100100
int i;
101101

102+
for ( i = 0; i < 100; i++ ) {
103+
x[ i ] = ( rand_double() * 20.0 ) - 10.0;
104+
y[ i ] = ( rand_double() * 2048.0 ) - 1024.0;
105+
}
106+
102107
t = tic();
103108
for ( i = 0; i < ITERATIONS; i++ ) {
104-
x = ( rand_double()*20.0 ) - 10.0;
105-
y = ( rand_double()*2048.0 ) - 1024.0;
106-
z = ldexp( x, y );
109+
z = ldexp( x[ i % 100 ], y[ i % 100 ] );
107110
if ( z != z ) {
108111
printf( "should not return NaN\n" );
109112
break;

0 commit comments

Comments
 (0)