Skip to content

Commit

Permalink
bench: refactor benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Oct 15, 2024
1 parent 870f645 commit 6c58a22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,18 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double values[ 10 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 10; i++ ) {
values[ i ] = ( 2.0*rand_double() ) - 1.0;
}
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 2.0*rand_double() ) - 1.0;
y = erf( x );
y = erf( values[ i%10 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,18 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double values[ 10 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 10; i++ ) {
values[ i ] = ( 2.0*rand_double() ) - 1.0;
}
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 2.0*rand_double() ) - 1.0;
y = erf( x );
y = erf( values[ i%10 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double values[ 10 ];
double elapsed;
double x;
double y;
double t;
int i;

for ( i = 0; i < 10; i++ ) {
values[ i ] = ( 2.0*rand_double() ) - 1.0;
}
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 2.0*rand_double() ) - 1.0;
y = stdlib_base_erf( x );
y = stdlib_base_erf( values[ i%10 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down

1 comment on commit 6c58a22

@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/erf $\color{red}870/882$
$\color{green}+98.64\%$
$\color{red}52/58$
$\color{green}+89.66\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{red}870/882$
$\color{green}+98.64\%$
math/base/special/exp2 $\color{green}327/327$
$\color{green}+100.00\%$
$\color{green}19/19$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}327/327$
$\color{green}+100.00\%$
math/base/special/floor $\color{green}157/157$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}157/157$
$\color{green}+100.00\%$
math/base/special/log $\color{green}171/171$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}171/171$
$\color{green}+100.00\%$
math/base/special/round $\color{green}236/236$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}236/236$
$\color{green}+100.00\%$

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

Please sign in to comment.