Skip to content

Commit

Permalink
bench: fix variable dtypes
Browse files Browse the repository at this point in the history
PR-URL: #2761
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com> 
Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
Signed-off-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
gunjjoshi and kgryte authored Aug 8, 2024
1 parent e9c6d40 commit 02d4c8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ static double tic( void ) {
*
* @return random number
*/
static double rand_double( void ) {
static float rand_float( void ) {
int r = rand();
return (double)r / ( (double)RAND_MAX + 1.0 );
return (float)r / ( (float)RAND_MAX + 1.0f );
}

/**
Expand All @@ -90,14 +90,14 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double y;
double t;
float x;
float y;
int i;

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
x = ( 1000.0f * rand_float() ) - 500.0f;
y = truncf( x );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ static double tic( void ) {
*
* @return random number
*/
static double rand_double( void ) {
static float rand_float( void ) {
int r = rand();
return (double)r / ( (double)RAND_MAX + 1.0 );
return (float)r / ( (float)RAND_MAX + 1.0f );
}

/**
Expand All @@ -91,14 +91,14 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double y;
double t;
float x;
float y;
int i;

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) - 500.0;
x = ( 1000.0f * rand_float() ) - 500.0f;
y = stdlib_base_truncf( x );
if ( y != y ) {
printf( "should not return NaN\n" );
Expand Down

1 comment on commit 02d4c8a

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
math/base/special/truncf $\color{green}201/201$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}201/201$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.