Skip to content

Commit

Permalink
Update benchmark.c
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Mathur <[email protected]>
  • Loading branch information
Harsh-Mathur-1503 authored Nov 12, 2024
1 parent 5e5440d commit 77b4697
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,26 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
unsigned long result;
double x;
double y;
double z;
double t;
int n;
int i;

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
n = rand_int();
result = stdlib_base_lcmf( n ); // Call to lcmf function
if ( result == 0 ) {
printf( "should not return 0 for n > 0\n" );
x = round( rand_double() * 500.0 );
y = round( rand_double() * 500.0 );
z = stdlib_base_lcmf( x, y );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( z != z ) {
printf( "should not return NaN\n" );
}
return elapsed;
}

Expand Down

0 comments on commit 77b4697

Please sign in to comment.