Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Dec 15, 2024
1 parent 002963d commit 59523e8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<details>

- [`6bbf2d6`](https://github.com/stdlib-js/stdlib/commit/6bbf2d67034e056190594bf2bceca4eb40a66b6f) - **style:** fix indentation _(by Philipp Burckhardt)_
- [`3b4514d`](https://github.com/stdlib-js/stdlib/commit/3b4514d1272ea9e4863381e3d0febd02ba8d230f) - **feat:** add `math/base/special/negalucasf` _(by Aayush Khanna, stdlib-bot, Philipp Burckhardt)_

</details>
Expand Down
96 changes: 48 additions & 48 deletions benchmark/c/native/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Prints the TAP version.
*/
void print_version() {
printf( "TAP version 13\n" );
printf( "TAP version 13\n" );
}

/**
Expand All @@ -41,12 +41,12 @@ void print_version() {
* @param passing total number of passing tests
*/
static void print_summary( int total, int passing ) {
printf( "#\n" );
printf( "1..%d\n", total ); // TAP plan
printf( "# total %d\n", total );
printf( "# pass %d\n", passing );
printf( "#\n" );
printf( "# ok\n" );
printf( "#\n" );
printf( "1..%d\n", total ); // TAP plan
printf( "# total %d\n", total );
printf( "# pass %d\n", passing );
printf( "#\n" );
printf( "# ok\n" );
}

/**
Expand All @@ -55,12 +55,12 @@ static void print_summary( int total, int passing ) {
* @param elapsed elapsed time in seconds
*/
static void print_results( double elapsed ) {
double rate = (double)ITERATIONS / elapsed;
printf( " ---\n" );
printf( " iterations: %d\n", ITERATIONS );
printf( " elapsed: %0.9f\n", elapsed );
printf( " rate: %0.9f\n", rate );
printf( " ...\n" );
double rate = (double)ITERATIONS / elapsed;
printf( " ---\n" );
printf( " iterations: %d\n", ITERATIONS );
printf( " elapsed: %0.9f\n", elapsed );
printf( " rate: %0.9f\n", rate );
printf( " ...\n" );
}

/**
Expand All @@ -69,9 +69,9 @@ static void print_results( double elapsed ) {
* @return clock time
*/
static double tic( void ) {
struct timeval now;
gettimeofday( &now, NULL );
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
struct timeval now;
gettimeofday( &now, NULL );
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
}

/**
Expand All @@ -80,8 +80,8 @@ static double tic( void ) {
* @return random number
*/
static float rand_float( void ) {
int r = rand();
return (float)r / ( (float)RAND_MAX + 1.0f );
int r = rand();
return (float)r / ( (float)RAND_MAX + 1.0f );
}

/**
Expand All @@ -90,47 +90,47 @@ static float rand_float( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double elapsed;
int32_t x[ 100 ];
double t;
float y;
int i;
double elapsed;
int32_t x[ 100 ];
double t;
float y;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = (int32_t)( 34.0f * rand_float() );
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_negalucasf( x[ i % 100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( y != y ) {
printf( "should not return NaN\n" );
}
return elapsed;
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_negalucasf( x[ i % 100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( y != y ) {
printf( "should not return NaN\n" );
}
return elapsed;
}

/**
* Main execution sequence.
*/
int main( void ) {
double elapsed;
int i;
double elapsed;
int i;

// Use the current time to seed the random number generator:
srand( time( NULL ) );
// Use the current time to seed the random number generator:
srand( time( NULL ) );

print_version();
for ( i = 0; i < REPEATS; i++ ) {
printf( "# c::native::%s\n", NAME );
elapsed = benchmark();
print_results( elapsed );
printf( "ok %d benchmark finished\n", i+1 );
}
print_summary( REPEATS, REPEATS );
print_version();
for ( i = 0; i < REPEATS; i++ ) {
printf( "# c::native::%s\n", NAME );
elapsed = benchmark();
print_results( elapsed );
printf( "ok %d benchmark finished\n", i+1 );
}
print_summary( REPEATS, REPEATS );
}

0 comments on commit 59523e8

Please sign in to comment.