Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ static double rand_double( void ) {
*/
static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double *x;
double v;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
for ( i = 0; i < len; i++ ) {
if ( rand_double() < 0.2 ) {
x[ i ] = 0.0 / 0.0; // NaN
Expand All @@ -121,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
if ( v != v ) {
printf( "should not return NaN\n" );
}

free(x);
return elapsed;
}

Expand All @@ -133,11 +136,12 @@ static double benchmark1( int iterations, int len ) {
*/
static double benchmark2( int iterations, int len ) {
double elapsed;
double x[ len ];
double *x;
double v;
double t;
int i;

x = (double *) malloc( len * sizeof( double ) );
for ( i = 0; i < len; i++ ) {
if ( rand_double() < 0.2 ) {
x[ i ] = 0.0 / 0.0; // NaN
Expand All @@ -158,6 +162,7 @@ static double benchmark2( int iterations, int len ) {
if ( v != v ) {
printf( "should not return NaN\n" );
}
free(x);
return elapsed;
}

Expand Down