Skip to content

Commit 00c1e27

Browse files
committedApr 14, 2025·
Auto-generated commit
1 parent 0d6fd66 commit 00c1e27

File tree

9 files changed

+42
-27
lines changed

9 files changed

+42
-27
lines changed
 

‎.github/.keepalive

-1
This file was deleted.

‎CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-04-07)
7+
## Unreleased (2025-04-14)
88

99
<section class="commits">
1010

1111
### Commits
1212

1313
<details>
1414

15+
- [`dededfd`](https://github.com/stdlib-js/stdlib/commit/dededfdc6102931758f0a12955d0054df893d849) - **bench:** update random value generation [(#6682)](https://github.com/stdlib-js/stdlib/pull/6682) _(by Harsh)_
1516
- [`2777e4b`](https://github.com/stdlib-js/stdlib/commit/2777e4be161869d09406e3b17947d24c64b47af2) - **bench:** resolve lint errors in benchmarks _(by Athan Reines)_
1617

1718
</details>
@@ -24,9 +25,10 @@
2425

2526
### Contributors
2627

27-
A total of 1 person contributed to this release. Thank you to this contributor:
28+
A total of 2 people contributed to this release. Thank you to the following contributors:
2829

2930
- Athan Reines
31+
- Harsh
3032

3133
</section>
3234

‎CONTRIBUTORS

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Joris Labie <joris.labie1@gmail.com>
7777
Justin Dennison <justin1dennison@gmail.com>
7878
Justyn Shelby <96994781+ShelbyJustyn@users.noreply.github.com>
7979
Karan Anand <anandkarancompsci@gmail.com>
80+
Karan Yadav <77043443+karanBRAVO@users.noreply.github.com>
8081
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
8182
Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
8283
Kavyansh-Bagdi <153486713+Kavyansh-Bagdi@users.noreply.github.com>
@@ -86,6 +87,7 @@ Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
8687
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
8788
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
8889
MANI <77221000+Eternity0207@users.noreply.github.com>
90+
Mahfuza Humayra Mohona <mhmohona@gmail.com>
8991
Manik Sharma <maniksharma.rke@gmail.com>
9092
Manvith M <148960168+manvith2003@users.noreply.github.com>
9193
Marcus Fantham <mfantham@users.noreply.github.com>
@@ -118,6 +120,7 @@ Prashant Kumar Yadav <144602492+0PrashantYadav0@users.noreply.github.com>
118120
PrathamBhamare <164445568+PrathamBhamare@users.noreply.github.com>
119121
Pratik Singh <97464067+Pratik772846@users.noreply.github.com>
120122
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
123+
Pravesh Kunwar <praveshkunwar04@gmail.com>
121124
Priyansh Prajapati <88396544+itsspriyansh@users.noreply.github.com>
122125
Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com>
123126
Pulkit Gupta <65711278+pulkitgupta2@users.noreply.github.com>

‎benchmark/benchmark.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var randu = require( '@stdlib/random-base-randu' );
25-
var round = require( '@stdlib/math-base-special-round' );
24+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
2625
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
2726
var pkg = require( './../package.json' ).name;
2827
var isNegativeInteger = require( './../lib' );
@@ -31,14 +30,19 @@ var isNegativeInteger = require( './../lib' );
3130
// MAIN //
3231

3332
bench( pkg, function benchmark( b ) {
33+
var opts;
3434
var x;
3535
var y;
3636
var i;
3737

38+
opts = {
39+
'dtype': 'float64'
40+
};
41+
x = discreteUniform( 100, -5.0e6, 5.0e6, opts );
42+
3843
b.tic();
3944
for ( i = 0; i < b.iterations; i++ ) {
40-
x = round( (randu()*1.0e7) - 5.0e6 );
41-
y = isNegativeInteger( x );
45+
y = isNegativeInteger( x[ i%x.length ] );
4246
if ( typeof y !== 'boolean' ) {
4347
b.fail( 'should return a boolean' );
4448
}

‎benchmark/benchmark.native.js

+8-4
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-harness' );
25-
var randu = require( '@stdlib/random-base-randu' );
26-
var round = require( '@stdlib/math-base-special-round' );
25+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
2726
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
2827
var tryRequire = require( '@stdlib/utils-try-require' );
2928
var pkg = require( './../package.json' ).name;
@@ -40,14 +39,19 @@ var opts = {
4039
// MAIN //
4140

4241
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var opts;
4343
var x;
4444
var y;
4545
var i;
4646

47+
opts = {
48+
'dtype': 'float64'
49+
};
50+
x = discreteUniform( 100, -5.0e6, 5.0e6, opts );
51+
4752
b.tic();
4853
for ( i = 0; i < b.iterations; i++ ) {
49-
x = round( (randu()*1.0e7) - 5.0e6 );
50-
y = isNegativeInteger( x );
54+
y = isNegativeInteger( x[ i%x.length ] );
5155
if ( typeof y !== 'boolean' ) {
5256
b.fail( 'should return a boolean' );
5357
}

‎benchmark/c/native/benchmark.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,18 @@ static double rand_double( void ) {
9292
*/
9393
static double benchmark( void ) {
9494
double elapsed;
95-
double x;
95+
double x[ 100 ];
9696
double t;
9797
bool b;
9898
int i;
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
x[ i ] = ( rand_double() * 200.0 ) - 100.0;
102+
}
103+
100104
t = tic();
101105
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = ( rand_double() * 200.0 ) - 100.0;
103-
b = stdlib_base_is_negative_integer( x );
106+
b = stdlib_base_is_negative_integer( x[ i%100 ] );
104107
if ( b != true && b != false ) {
105108
printf( "should return either true or false\n" );
106109
break;

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"@stdlib/boolean-ctor": "^0.2.2",
4949
"@stdlib/constants-float64-ninf": "^0.2.2",
5050
"@stdlib/constants-float64-pinf": "^0.2.2",
51-
"@stdlib/math-base-special-round": "^0.3.0",
5251
"@stdlib/math-base-special-trunc": "^0.2.2",
52+
"@stdlib/random-array-discrete-uniform": "^0.2.1",
5353
"@stdlib/random-base-randu": "^0.2.1",
5454
"@stdlib/utils-try-require": "^0.2.2",
5555
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",

‎test/test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ tape( 'main export is a function', function test( t ) {
3939
tape( 'the function returns `false` if provided a nonnegative integer', function test( t ) {
4040
var i;
4141
for ( i = 0; i < 101; i++ ) {
42-
t.equal( isNegativeInteger( i ), false, 'returns false when provided '+i );
42+
t.equal( isNegativeInteger( i ), false, 'returns expected value when provided '+i );
4343
}
4444
t.end();
4545
});
4646

4747
tape( 'the function returns `true` if provided a negative integer', function test( t ) {
4848
var i;
4949
for ( i = -1; i > -101; i-- ) {
50-
t.equal( isNegativeInteger( i ), true, 'returns true when provided '+i );
50+
t.equal( isNegativeInteger( i ), true, 'returns expected value when provided '+i );
5151
}
5252
t.end();
5353
});
@@ -58,23 +58,23 @@ tape( 'the function returns `false` if not provided an integer', function test(
5858
for ( i = 0; i < 100; i++ ) {
5959
v = ( randu()*100.0 ) - 50.0;
6060
if ( trunc(v) !== v ) {
61-
t.equal( isNegativeInteger( v ), false, 'returns false when provided '+v );
61+
t.equal( isNegativeInteger( v ), false, 'returns expected value when provided '+v );
6262
}
6363
}
6464
t.end();
6565
});
6666

6767
tape( 'the function returns `false` if provided `NaN`', function test( t ) {
68-
t.equal( isNegativeInteger( NaN ), false, 'returns false' );
68+
t.equal( isNegativeInteger( NaN ), false, 'returns expected value' );
6969
t.end();
7070
});
7171

7272
tape( 'WARNING: the function returns `true` if provided `-infinity`', function test( t ) {
73-
t.equal( isNegativeInteger( NINF ), true, 'returns true' );
73+
t.equal( isNegativeInteger( NINF ), true, 'returns expected value' );
7474
t.end();
7575
});
7676

7777
tape( 'the function returns `false` if provided `+infinity`', function test( t ) {
78-
t.equal( isNegativeInteger( PINF ), false, 'returns false' );
78+
t.equal( isNegativeInteger( PINF ), false, 'returns expected value' );
7979
t.end();
8080
});

‎test/test.native.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ tape( 'main export is a function', opts, function test( t ) {
4848
tape( 'the function returns `false` if provided a nonnegative integer', opts, function test( t ) {
4949
var i;
5050
for ( i = 0; i < 101; i++ ) {
51-
t.equal( isNegativeInteger( i ), false, 'returns false when provided '+i );
51+
t.equal( isNegativeInteger( i ), false, 'returns expected value when provided '+i );
5252
}
5353
t.end();
5454
});
5555

5656
tape( 'the function returns `true` if provided a negative integer', opts, function test( t ) {
5757
var i;
5858
for ( i = -1; i > -101; i-- ) {
59-
t.equal( isNegativeInteger( i ), true, 'returns true when provided '+i );
59+
t.equal( isNegativeInteger( i ), true, 'returns expected value when provided '+i );
6060
}
6161
t.end();
6262
});
@@ -67,23 +67,23 @@ tape( 'the function returns `false` if not provided an integer', opts, function
6767
for ( i = 0; i < 100; i++ ) {
6868
v = ( randu()*100.0 ) - 50.0;
6969
if ( trunc(v) !== v ) {
70-
t.equal( isNegativeInteger( v ), false, 'returns false when provided '+v );
70+
t.equal( isNegativeInteger( v ), false, 'returns expected value when provided '+v );
7171
}
7272
}
7373
t.end();
7474
});
7575

7676
tape( 'the function returns `false` if provided `NaN`', opts, function test( t ) {
77-
t.equal( isNegativeInteger( NaN ), false, 'returns false' );
77+
t.equal( isNegativeInteger( NaN ), false, 'returns expected value' );
7878
t.end();
7979
});
8080

8181
tape( 'WARNING: the function returns `true` if provided `-infinity`', opts, function test( t ) {
82-
t.equal( isNegativeInteger( NINF ), true, 'returns true' );
82+
t.equal( isNegativeInteger( NINF ), true, 'returns expected value' );
8383
t.end();
8484
});
8585

8686
tape( 'the function returns `false` if provided `+infinity`', opts, function test( t ) {
87-
t.equal( isNegativeInteger( PINF ), false, 'returns false' );
87+
t.equal( isNegativeInteger( PINF ), false, 'returns expected value' );
8888
t.end();
8989
});

0 commit comments

Comments
 (0)
Please sign in to comment.