Skip to content

Commit c4605e7

Browse files
committed
Auto-generated commit
1 parent 9f5d7f3 commit c4605e7

9 files changed

Lines changed: 41 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<details>
2424

25+
- [`3a6a913`](https://github.com/stdlib-js/stdlib/commit/3a6a913fe41d3ffbbb4f73837fc6aa8396cdccce) - **bench:** update random value generation [(#6377)](https://github.com/stdlib-js/stdlib/pull/6377) _(by Harsh)_
2526
- [`a644ffe`](https://github.com/stdlib-js/stdlib/commit/a644ffeba579430f342444b80fa9d21cc4a635f4) - **chore:** remove obsolete accuracy and precision scripts [(#6435)](https://github.com/stdlib-js/stdlib/pull/6435) _(by Karan Anand)_
2627
- [`4301694`](https://github.com/stdlib-js/stdlib/commit/43016945387e02d6396d33cb7134c62c977b7fd8) - **docs:** update related packages sections [(#4362)](https://github.com/stdlib-js/stdlib/pull/4362) _(by stdlib-bot)_
2728
- [`e450426`](https://github.com/stdlib-js/stdlib/commit/e450426813957ec4de5e31434edb969741db7c94) - **bench:** add missing native suffix _(by Philipp Burckhardt)_
@@ -41,9 +42,10 @@
4142

4243
### Contributors
4344

44-
A total of 3 people contributed to this release. Thank you to the following contributors:
45+
A total of 4 people contributed to this release. Thank you to the following contributors:
4546

4647
- Athan Reines
48+
- Harsh
4749
- Karan Anand
4850
- Philipp Burckhardt
4951

benchmark/benchmark.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
24+
var uniform = require( '@stdlib/random-array-uniform' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var log2 = require( './../lib' );
@@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
4141
var y;
4242
var i;
4343

44+
x = uniform( 100, 0.0, 1000.0 );
45+
4446
b.tic();
4547
for ( i = 0; i < b.iterations; i++ ) {
46-
x = ( randu()*1000.0 ) - 0.0;
47-
y = log2( x );
48+
y = log2( x[ i%x.length ] );
4849
if ( isnan( y ) ) {
4950
b.fail( 'should not return NaN' );
5051
}
@@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) {
6263
var y;
6364
var i;
6465

66+
x = uniform( 100, 0.0, 1000.0 );
67+
6568
b.tic();
6669
for ( i = 0; i < b.iterations; i++ ) {
67-
x = ( randu()*1000.0 ) - 0.0;
68-
y = Math.log2( x ); // eslint-disable-line stdlib/no-builtin-math
70+
y = Math.log2( x[ i%x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6971
if ( isnan( y ) ) {
7072
b.fail( 'should not return NaN' );
7173
}

benchmark/benchmark.native.js

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
25-
var randu = require( '@stdlib/random-base-randu' );
25+
var uniform = require( '@stdlib/random-array-uniform' );
2626
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2727
var tryRequire = require( '@stdlib/utils-try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, 0.0, 1000.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*1000.0 ) - 0.0;
49-
y = log2( x );
50+
y = log2( x[ i%x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

benchmark/c/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ static double rand_double( void ) {
9090
*/
9191
static double benchmark( void ) {
9292
double elapsed;
93-
double x;
93+
double x[ 100 ];
9494
double y;
9595
double t;
9696
int i;
9797

98+
for ( i = 0; i < 100; i++ ) {
99+
x[ i ] = ( 1000.0*rand_double() ) - 0.0;
100+
}
101+
98102
t = tic();
99103
for ( i = 0; i < ITERATIONS; i++ ) {
100-
x = ( 1000.0*rand_double() ) - 0.0;
101-
y = log2( x );
104+
y = log2( x[ i%100 ] );
102105
if ( y != y ) {
103106
printf( "should not return NaN\n" );
104107
break;

benchmark/c/cephes/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,18 @@ static double rand_double( void ) {
9595
*/
9696
static double benchmark( void ) {
9797
double elapsed;
98-
double x;
98+
double x[ 100 ];
9999
double y;
100100
double t;
101101
int i;
102102

103+
for ( i = 0; i < 100; i++ ) {
104+
x[ i ] = ( 1000.0*rand_double() ) - 0.0;
105+
}
106+
103107
t = tic();
104108
for ( i = 0; i < ITERATIONS; i++ ) {
105-
x = ( 1000.0*rand_double() ) - 0.0;
106-
y = log2( x );
109+
y = log2( x[ i%100 ] );
107110
if ( y != y ) {
108111
printf( "should not return NaN\n" );
109112
break;

benchmark/c/native/benchmark.c

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

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@stdlib/math-base-assert-is-positive-zero": "^0.2.2",
6161
"@stdlib/math-base-special-abs": "^0.2.2",
6262
"@stdlib/math-base-special-round": "^0.3.0",
63+
"@stdlib/random-array-uniform": "^0.2.1",
6364
"@stdlib/random-base-randu": "^0.2.1",
6465
"@stdlib/utils-try-require": "^0.2.2",
6566
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",

test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,23 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', f
211211
});
212212

213213
tape( 'the function returns `-infinity` if provided `0`', function test( t ) {
214-
t.equal( log2( 0.0 ), NINF, 'equals -infinity' );
214+
t.equal( log2( 0.0 ), NINF, 'returns expected value' );
215215
t.end();
216216
});
217217

218218
tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) {
219-
t.equal( log2( PINF ), PINF, 'equals +infinity' );
219+
t.equal( log2( PINF ), PINF, 'returns expected value' );
220220
t.end();
221221
});
222222

223223
tape( 'the function returns `NaN` if provided a negative number', function test( t ) {
224224
var v = log2( -1.0 );
225-
t.equal( isnan( v ), true, 'returns NaN' );
225+
t.equal( isnan( v ), true, 'returns expected value' );
226226
t.end();
227227
});
228228

229229
tape( 'the function returns positive zero if provided `1.0`', function test( t ) {
230230
var v = log2( 1.0 );
231-
t.equal( isPositiveZero( v ), true, 'returns +0' );
231+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
232232
t.end();
233233
});

test/test.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,23 @@ tape( 'the function evaluates the binary logarithm of `x` (subnormal values)', o
220220
});
221221

222222
tape( 'the function returns `-infinity` if provided `0`', opts, function test( t ) {
223-
t.equal( log2( 0.0 ), NINF, 'equals -infinity' );
223+
t.equal( log2( 0.0 ), NINF, 'returns expected value' );
224224
t.end();
225225
});
226226

227227
tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) {
228-
t.equal( log2( PINF ), PINF, 'equals +infinity' );
228+
t.equal( log2( PINF ), PINF, 'returns expected value' );
229229
t.end();
230230
});
231231

232232
tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) {
233233
var v = log2( -1.0 );
234-
t.equal( isnan( v ), true, 'returns NaN' );
234+
t.equal( isnan( v ), true, 'returns expected value' );
235235
t.end();
236236
});
237237

238238
tape( 'the function returns positive zero if provided `1.0`', opts, function test( t ) {
239239
var v = log2( 1.0 );
240-
t.equal( isPositiveZero( v ), true, 'returns +0' );
240+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
241241
t.end();
242242
});

0 commit comments

Comments
 (0)