Skip to content

Commit 66a0a8c

Browse files
author
aayush0325
committed
feat: updated benchmarks with pre-computation
1 parent 0a221ce commit 66a0a8c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/node_modules/@stdlib/math/base/special/lucasf/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bench( pkg+'::recursion_memoized', function benchmark( b ) {
154154

155155
b.tic();
156156
for ( i = 0; i < b.iterations; i++ ) {
157-
x = floorf( randu() * 40.0 ); // limit upper bound
157+
x = floorf( randu() * 35.0 ); // limit upper bound
158158
y = lucasf( x );
159159
if ( isnanf( y ) ) {
160160
b.fail( 'should not return NaN' );

lib/node_modules/@stdlib/math/base/special/lucasf/benchmark/benchmark.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var floorf = require( '@stdlib/math/base/special/floorf' );
25+
var randu = require( '@stdlib/random/array/discrete-uniform' );
2726
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
2928
var pkg = require( './../package.json' ).name;
@@ -44,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4443
var y;
4544
var i;
4645

46+
x = randu( 100, -50, 50 );
47+
4748
b.tic();
4849
for ( i = 0; i < b.iterations; i++ ) {
49-
x = floorf( randu() * 34.0 );
50-
y = lucasf( x );
50+
y = lucasf( x[ i % 100 ] );
5151
if ( isnanf( y ) ) {
5252
b.fail( 'should not return NaN' );
5353
}

lib/node_modules/@stdlib/math/base/special/lucasf/benchmark/c/native/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static float rand_float( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
int32_t x;
94+
int32_t x[ 100 ];
9595
double t;
9696
float y;
9797
int i;
9898

99+
for ( i = 0 ; i < 100 ; i++ ) {
100+
x[ i ] = ( int32_t )( 34.0f * rand_float() );
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = (int32_t)( 34.0f * rand_float() );
102-
y = stdlib_base_lucasf( x );
105+
y = stdlib_base_lucasf( x[ i % 100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

0 commit comments

Comments
 (0)