Skip to content

Commit ddd8272

Browse files
committed
Auto-generated commit
1 parent a832b06 commit ddd8272

22 files changed

+159
-121
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9095,6 +9095,7 @@ A total of 25 people contributed to this release. Thank you to the following con
90959095

90969096
<details>
90979097

9098+
- [`b103cae`](https://github.com/stdlib-js/stdlib/commit/b103caebeb565cdcdc08a76cd131ad1ea0b55a27) - **bench:** update random value generation [(#6301)](https://github.com/stdlib-js/stdlib/pull/6301) _(by Harsh, stdlib-bot)_
90989099
- [`6187773`](https://github.com/stdlib-js/stdlib/commit/6187773d4d95c73e0e8a8f6c43dcd53d5323f9d2) - **bench:** update random value generation [(#6298)](https://github.com/stdlib-js/stdlib/pull/6298) _(by Harsh)_
90999100
- [`44445ab`](https://github.com/stdlib-js/stdlib/commit/44445ab0a65a29e3bb593a11f87d9035e552474f) - **bench:** update random value generation [(#6302)](https://github.com/stdlib-js/stdlib/pull/6302) _(by Harsh)_
91009101
- [`d3bf998`](https://github.com/stdlib-js/stdlib/commit/d3bf998980b55e4a0ad53ad3b9053c9b12204b0e) - **bench:** update random value generation [(#6269)](https://github.com/stdlib-js/stdlib/pull/6269) _(by Harsh, Athan Reines)_

base/special/copysign/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( './../../../../base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var copysign = require( './../lib' );
@@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
3535
var z;
3636
var i;
3737

38+
x = uniform( 100, -5.0e6, 5.0e6 );
39+
y = uniform( 100, -5.0e6, 5.0e6 );
40+
3841
b.tic();
3942
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*1.0e7 ) - 5.0e6;
41-
y = ( randu()*1.0e7 ) - 5.0e6;
42-
z = copysign( x, y );
43+
z = copysign( x[ i%x.length ], y[ i%y.length ] );
4344
if ( isnan( z ) ) {
4445
b.fail( 'should not return NaN' );
4546
}

base/special/copysign/benchmark/benchmark.native.js

+5-4
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' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnan = require( './../../../../base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4444
var z;
4545
var i;
4646

47+
x = uniform( 100, -5.0e6, 5.0e6 );
48+
y = uniform( 100, -5.0e6, 5.0e6 );
49+
4750
b.tic();
4851
for ( i = 0; i < b.iterations; i++ ) {
49-
x = ( randu()*1.0e7 ) - 5.0e6;
50-
y = ( randu()*1.0e7 ) - 5.0e6;
51-
z = copysign( x, y );
52+
z = copysign( x[ i%x.length ], y[ i%y.length ] );
5253
if ( isnan( z ) ) {
5354
b.fail( 'should not return NaN' );
5455
}

base/special/copysign/benchmark/c/benchmark.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,20 @@ static double rand_double( void ) {
9090
*/
9191
static double benchmark( void ) {
9292
double elapsed;
93-
double x;
94-
double y;
93+
double x[ 100 ];
94+
double y[ 100 ];
9595
double z;
9696
double t;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 1.0e7*rand_double() ) - 5.0e6;
101+
y[ i ] = ( 1.0e7*rand_double() ) - 5.0e6;
102+
}
103+
99104
t = tic();
100105
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 1.0e7*rand_double() ) - 5.0e6;
102-
y = ( 1.0e7*rand_double() ) - 5.0e6;
103-
z = copysign( x, y );
106+
z = copysign( x[ i%100 ], y[ i%100 ] );
104107
if ( z != z ) {
105108
printf( "should not return NaN\n" );
106109
break;

base/special/copysign/benchmark/c/native/benchmark.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,20 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
95-
double y;
94+
double x[ 100 ];
95+
double y[ 100 ];
9696
double z;
9797
double t;
9898
int i;
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
x[ i ] = ( 1.0e7*rand_double() ) - 5.0e6;
102+
y[ i ] = ( 1.0e7*rand_double() ) - 5.0e6;
103+
}
104+
100105
t = tic();
101106
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = ( 1.0e7*rand_double() ) - 5.0e6;
103-
y = ( 1.0e7*rand_double() ) - 5.0e6;
104-
z = stdlib_base_copysign( x, y );
107+
z = stdlib_base_copysign( x[ i%100 ], y[ i%100 ] );
105108
if ( z != z ) {
106109
printf( "should not return NaN\n" );
107110
break;

base/special/copysign/test/test.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ tape( 'if `x` is `NaN`, the function returns `NaN`', function test( t ) {
6363
var z;
6464

6565
z = copysign( NaN, -1.0 );
66-
t.equal( isnan( z ), true, 'returns NaN' );
66+
t.equal( isnan( z ), true, 'returns expected value' );
6767

6868
z = copysign( NaN, 1.0 );
69-
t.equal( isnan( z ), true, 'returns NaN' );
69+
t.equal( isnan( z ), true, 'returns expected value' );
7070

7171
t.end();
7272
});
@@ -87,10 +87,10 @@ tape( 'if `x` is `+infinity`, the function returns an infinite number', function
8787
var z;
8888

8989
z = copysign( PINF, -1.0 );
90-
t.equal( z, NINF, 'returns -infinity' );
90+
t.equal( z, NINF, 'returns expected value' );
9191

9292
z = copysign( PINF, 1.0 );
93-
t.equal( z, PINF, 'returns +infinity' );
93+
t.equal( z, PINF, 'returns expected value' );
9494

9595
t.end();
9696
});
@@ -99,10 +99,10 @@ tape( 'if `y` is `+infinity`, the function returns a positive number', function
9999
var z;
100100

101101
z = copysign( -1.0, PINF );
102-
t.equal( z, 1.0, 'returns +1' );
102+
t.equal( z, 1.0, 'returns expected value' );
103103

104104
z = copysign( 1.0, PINF );
105-
t.equal( z, 1.0, 'returns +1' );
105+
t.equal( z, 1.0, 'returns expected value' );
106106

107107
t.end();
108108
});
@@ -111,10 +111,10 @@ tape( 'if `x` is `-infinity`, the function returns an infinite number', function
111111
var z;
112112

113113
z = copysign( NINF, -1.0 );
114-
t.equal( z, NINF, 'returns -infinity' );
114+
t.equal( z, NINF, 'returns expected value' );
115115

116116
z = copysign( NINF, 1.0 );
117-
t.equal( z, PINF, 'returns +infinity' );
117+
t.equal( z, PINF, 'returns expected value' );
118118

119119
t.end();
120120
});
@@ -123,10 +123,10 @@ tape( 'if `y` is `-infinity`, the function returns a negative number', function
123123
var z;
124124

125125
z = copysign( -1.0, NINF );
126-
t.equal( z, -1.0, 'returns -1' );
126+
t.equal( z, -1.0, 'returns expected value' );
127127

128128
z = copysign( 1.0, NINF );
129-
t.equal( z, -1.0, 'returns -1' );
129+
t.equal( z, -1.0, 'returns expected value' );
130130

131131
t.end();
132132
});
@@ -138,10 +138,10 @@ tape( 'the function supports copying a sign from `0`', function test( t ) {
138138
x = 3.14;
139139

140140
z = copysign( x, 0.0 );
141-
t.equal( z, 3.14, 'returns +3.14' );
141+
t.equal( z, 3.14, 'returns expected value' );
142142

143143
z = copysign( x, -0.0 );
144-
t.equal( z, -3.14, 'returns -3.14' );
144+
t.equal( z, -3.14, 'returns expected value' );
145145

146146
t.end();
147147
});
@@ -150,10 +150,10 @@ tape( 'the function supports copying a sign to `0`', function test( t ) {
150150
var z;
151151

152152
z = copysign( -0.0, 1.0 );
153-
t.equal( isPositiveZero( z ), true, 'returns +0' );
153+
t.equal( isPositiveZero( z ), true, 'returns expected value' );
154154

155155
z = copysign( 0.0, -1.0 );
156-
t.equal( isNegativeZero( z ), true, 'returns -0' );
156+
t.equal( isNegativeZero( z ), true, 'returns expected value' );
157157

158158
t.end();
159159
});

base/special/copysign/test/test.native.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ tape( 'if `x` is `NaN`, the function returns `NaN`', opts, function test( t ) {
7272
var z;
7373

7474
z = copysign( NaN, -1.0 );
75-
t.equal( isnan( z ), true, 'returns NaN' );
75+
t.equal( isnan( z ), true, 'returns expected value' );
7676

7777
z = copysign( NaN, 1.0 );
78-
t.equal( isnan( z ), true, 'returns NaN' );
78+
t.equal( isnan( z ), true, 'returns expected value' );
7979

8080
t.end();
8181
});
@@ -96,10 +96,10 @@ tape( 'if `x` is `+infinity`, the function returns an infinite number', opts, fu
9696
var z;
9797

9898
z = copysign( PINF, -1.0 );
99-
t.equal( z, NINF, 'returns -infinity' );
99+
t.equal( z, NINF, 'returns expected value' );
100100

101101
z = copysign( PINF, 1.0 );
102-
t.equal( z, PINF, 'returns +infinity' );
102+
t.equal( z, PINF, 'returns expected value' );
103103

104104
t.end();
105105
});
@@ -108,10 +108,10 @@ tape( 'if `y` is `+infinity`, the function returns a positive number', opts, fun
108108
var z;
109109

110110
z = copysign( -1.0, PINF );
111-
t.equal( z, 1.0, 'returns +1' );
111+
t.equal( z, 1.0, 'returns expected value' );
112112

113113
z = copysign( 1.0, PINF );
114-
t.equal( z, 1.0, 'returns +1' );
114+
t.equal( z, 1.0, 'returns expected value' );
115115

116116
t.end();
117117
});
@@ -120,10 +120,10 @@ tape( 'if `x` is `-infinity`, the function returns an infinite number', opts, fu
120120
var z;
121121

122122
z = copysign( NINF, -1.0 );
123-
t.equal( z, NINF, 'returns -infinity' );
123+
t.equal( z, NINF, 'returns expected value' );
124124

125125
z = copysign( NINF, 1.0 );
126-
t.equal( z, PINF, 'returns +infinity' );
126+
t.equal( z, PINF, 'returns expected value' );
127127

128128
t.end();
129129
});
@@ -132,10 +132,10 @@ tape( 'if `y` is `-infinity`, the function returns a negative number', opts, fun
132132
var z;
133133

134134
z = copysign( -1.0, NINF );
135-
t.equal( z, -1.0, 'returns -1' );
135+
t.equal( z, -1.0, 'returns expected value' );
136136

137137
z = copysign( 1.0, NINF );
138-
t.equal( z, -1.0, 'returns -1' );
138+
t.equal( z, -1.0, 'returns expected value' );
139139

140140
t.end();
141141
});
@@ -147,10 +147,10 @@ tape( 'the function supports copying a sign from `0`', opts, function test( t )
147147
x = 3.14;
148148

149149
z = copysign( x, 0.0 );
150-
t.equal( z, 3.14, 'returns +3.14' );
150+
t.equal( z, 3.14, 'returns expected value' );
151151

152152
z = copysign( x, -0.0 );
153-
t.equal( z, -3.14, 'returns -3.14' );
153+
t.equal( z, -3.14, 'returns expected value' );
154154

155155
t.end();
156156
});
@@ -159,10 +159,10 @@ tape( 'the function supports copying a sign to `0`', opts, function test( t ) {
159159
var z;
160160

161161
z = copysign( -0.0, 1.0 );
162-
t.equal( isPositiveZero( z ), true, 'returns +0' );
162+
t.equal( isPositiveZero( z ), true, 'returns expected value' );
163163

164164
z = copysign( 0.0, -1.0 );
165-
t.equal( isNegativeZero( z ), true, 'returns -0' );
165+
t.equal( isNegativeZero( z ), true, 'returns expected value' );
166166

167167
t.end();
168168
});

base/special/copysignf/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnanf = require( './../../../../base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var copysignf = require( './../lib' );
@@ -35,11 +35,16 @@ bench( pkg, function benchmark( b ) {
3535
var z;
3636
var i;
3737

38+
x = uniform( 100, -5.0e6, 5.0e6, {
39+
'dtype': 'float32'
40+
});
41+
y = uniform( 100, -5.0e6, 5.0e6, {
42+
'dtype': 'float32'
43+
});
44+
3845
b.tic();
3946
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*1.0e7 ) - 5.0e6;
41-
y = ( randu()*1.0e7 ) - 5.0e6;
42-
z = copysignf( x, y );
47+
z = copysignf( x[ i%x.length ], y[ i%y.length ] );
4348
if ( isnanf( z ) ) {
4449
b.fail( 'should not return NaN' );
4550
}

base/special/copysignf/benchmark/benchmark.native.js

+9-4
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' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnanf = require( './../../../../base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -44,11 +44,16 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4444
var z;
4545
var i;
4646

47+
x = uniform( 100, -5.0e6, 5.0e6, {
48+
'dtype': 'float32'
49+
});
50+
y = uniform( 100, -5.0e6, 5.0e6, {
51+
'dtype': 'float32'
52+
});
53+
4754
b.tic();
4855
for ( i = 0; i < b.iterations; i++ ) {
49-
x = ( randu()*1.0e7 ) - 5.0e6;
50-
y = ( randu()*1.0e7 ) - 5.0e6;
51-
z = copysignf( x, y );
56+
z = copysignf( x[ i%x.length ], y[ i%y.length ] );
5257
if ( isnanf( z ) ) {
5358
b.fail( 'should not return NaN' );
5459
}

base/special/copysignf/benchmark/c/benchmark.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ static float rand_float( void ) {
9191
static double benchmark( void ) {
9292
double elapsed;
9393
double t;
94-
float x;
95-
float y;
94+
float x[ 100 ];
95+
float y[ 100 ];
9696
float z;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 1000.0f*rand_float() ) - 500.0f;
101+
y[ i ] = ( 1000.0f*rand_float() ) - 500.0f;
102+
}
103+
99104
t = tic();
100105
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 1000.0f*rand_float() ) - 500.0f;
102-
y = ( 1000.0f*rand_float() ) - 500.0f;
103-
z = copysignf( x, y );
106+
z = copysignf( x[ i%100 ], y[ i%100 ] );
104107
if ( z != z ) {
105108
printf( "should not return NaN\n" );
106109
break;

base/special/copysignf/benchmark/c/native/benchmark.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ static float rand_float( void ) {
9292
static double benchmark( void ) {
9393
double elapsed;
9494
double t;
95-
float x;
96-
float y;
95+
float x[ 100 ];
96+
float y[ 100 ];
9797
float z;
9898
int i;
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
x[ i ] = ( 1000.0f*rand_float() ) - 500.0f;
102+
y[ i ] = ( 1000.0f*rand_float() ) - 500.0f;
103+
}
104+
100105
t = tic();
101106
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = ( 1000.0f*rand_float() ) - 500.0f;
103-
y = ( 1000.0f*rand_float() ) - 500.0f;
104-
z = stdlib_base_copysignf( x, y );
107+
z = stdlib_base_copysignf( x[ i%100 ], y[ i%100 ] );
105108
if ( z != z ) {
106109
printf( "should not return NaN\n" );
107110
break;

0 commit comments

Comments
 (0)