Skip to content

Commit c9560de

Browse files
bench: refactor to use logEachMap in examples
PR-URL: #11454 Reviewed-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Neeraj Pathak <neerajrpathak710@gmail.com>
1 parent a503990 commit c9560de

File tree

18 files changed

+86
-158
lines changed

18 files changed

+86
-158
lines changed

lib/node_modules/@stdlib/number/float32/base/add/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ v = addf( NaN, NaN );
8282
<!-- eslint no-undef: "error" -->
8383

8484
```javascript
85-
var rand = require( '@stdlib/random/base/discrete-uniform' );
85+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
86+
var logEachMap = require( '@stdlib/console/log-each-map' );
8687
var addf = require( '@stdlib/number/float32/base/add' );
8788

88-
var x;
89-
var y;
90-
var i;
89+
var x = discreteUniform( 100, -50, 50 );
90+
var y = discreteUniform( 100, -50, 50 );
9191

92-
for ( i = 0; i < 100; i++ ) {
93-
x = rand( -50, 50 );
94-
y = rand( -50, 50 );
95-
console.log( '%d + %d = %d', x, y, addf( x, y ) );
96-
}
92+
logEachMap( '%d + %d = %d', x, y, addf );
9793
```
9894

9995
</section>

lib/node_modules/@stdlib/number/float32/base/add/examples/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
'use strict';
2020

21-
var rand = require( '@stdlib/random/base/discrete-uniform' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var addf = require( './../lib' );
2324

24-
var x;
25-
var y;
26-
var i;
25+
var x = discreteUniform( 100, -50, 50 );
26+
var y = discreteUniform( 100, -50, 50 );
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
x = rand( -50, 50 );
30-
y = rand( -50, 50 );
31-
console.log( '%d + %d = %d', x, y, addf( x, y ) );
32-
}
28+
logEachMap( '%d + %d = %d', x, y, addf );

lib/node_modules/@stdlib/number/float32/base/div/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ v = divf( NaN, NaN );
8282
<!-- eslint no-undef: "error" -->
8383

8484
```javascript
85-
var rand = require( '@stdlib/random/base/discrete-uniform' );
85+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
86+
var logEachMap = require( '@stdlib/console/log-each-map' );
8687
var divf = require( '@stdlib/number/float32/base/div' );
8788

88-
var x;
89-
var y;
90-
var i;
89+
var x = discreteUniform( 100, -50, 50 );
90+
var y = discreteUniform( 100, -50, 50 );
9191

92-
for ( i = 0; i < 100; i++ ) {
93-
x = rand( -50, 50 );
94-
y = rand( -50, 50 );
95-
console.log( '%d / %d = %d', x, y, divf( x, y ) );
96-
}
92+
logEachMap( '%d / %d = %d', x, y, divf );
9793
```
9894

9995
</section>

lib/node_modules/@stdlib/number/float32/base/div/examples/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
'use strict';
2020

21-
var rand = require( '@stdlib/random/base/discrete-uniform' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var divf = require( './../lib' );
2324

24-
var x;
25-
var y;
26-
var i;
25+
var x = discreteUniform( 100, -50, 50 );
26+
var y = discreteUniform( 100, -50, 50 );
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
x = rand( -50, 50 );
30-
y = rand( -50, 50 );
31-
console.log( '%d / %d = %d', x, y, divf( x, y ) );
32-
}
28+
logEachMap( '%d / %d = %d', x, y, divf );

lib/node_modules/@stdlib/number/float32/base/identity/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,13 @@ v = identityf( NaN );
8585
<!-- eslint no-undef: "error" -->
8686

8787
```javascript
88-
var randu = require( '@stdlib/random/base/randu' );
89-
var round = require( '@stdlib/math/base/special/round' );
88+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
89+
var logEachMap = require( '@stdlib/console/log-each-map' );
9090
var identityf = require( '@stdlib/number/float32/base/identity' );
9191

92-
var rand;
93-
var i;
92+
var x = discreteUniform( 100, -50, 50 );
9493

95-
for ( i = 0; i < 100; i++ ) {
96-
rand = round( randu() * 100.0 ) - 50.0;
97-
console.log( 'identity(%d) = %d', rand, identityf( rand ) );
98-
}
94+
logEachMap( 'identity(%d) = %d', x, identityf );
9995
```
10096

10197
</section>

lib/node_modules/@stdlib/number/float32/base/identity/examples/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var identityf = require( './../lib' );
2424

25-
var rand;
26-
var i;
25+
var x = discreteUniform( 100, -50, 50 );
2726

28-
for ( i = 0; i < 100; i++ ) {
29-
rand = round( randu() * 100.0 ) - 50.0;
30-
console.log( 'identity(%d) = %d', rand, identityf( rand ) );
31-
}
27+
logEachMap( 'identity(%d) = %d', x, identityf );

lib/node_modules/@stdlib/number/float32/base/mul/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ v = mulf( NaN, NaN );
8282
<!-- eslint no-undef: "error" -->
8383

8484
```javascript
85-
var rand = require( '@stdlib/random/base/discrete-uniform' );
85+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
86+
var logEachMap = require( '@stdlib/console/log-each-map' );
8687
var mulf = require( '@stdlib/number/float32/base/mul' );
8788

88-
var x;
89-
var y;
90-
var i;
89+
var x = discreteUniform( 100, -50, 50 );
90+
var y = discreteUniform( 100, -50, 50 );
9191

92-
for ( i = 0; i < 100; i++ ) {
93-
x = rand( -50, 50 );
94-
y = rand( -50, 50 );
95-
console.log( '%d x %d = %d', x, y, mulf( x, y ) );
96-
}
92+
logEachMap( '%d x %d = %d', x, y, mulf );
9793
```
9894

9995
</section>

lib/node_modules/@stdlib/number/float32/base/mul/examples/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
'use strict';
2020

21-
var rand = require( '@stdlib/random/base/discrete-uniform' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var mulf = require( './../lib' );
2324

24-
var x;
25-
var y;
26-
var i;
25+
var x = discreteUniform( 100, -50, 50 );
26+
var y = discreteUniform( 100, -50, 50 );
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
x = rand( -50, 50 );
30-
y = rand( -50, 50 );
31-
console.log( '%d x %d = %d', x, y, mulf( x, y ) );
32-
}
28+
logEachMap( '%d x %d = %d', x, y, mulf );

lib/node_modules/@stdlib/number/float32/base/sub/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ v = subf( NaN, NaN );
8282
<!-- eslint no-undef: "error" -->
8383

8484
```javascript
85-
var rand = require( '@stdlib/random/base/discrete-uniform' );
85+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
86+
var logEachMap = require( '@stdlib/console/log-each-map' );
8687
var subf = require( '@stdlib/number/float32/base/sub' );
8788

88-
var x;
89-
var y;
90-
var i;
89+
var x = discreteUniform( 100, -50, 50 );
90+
var y = discreteUniform( 100, -50, 50 );
9191

92-
for ( i = 0; i < 100; i++ ) {
93-
x = rand( -50, 50 );
94-
y = rand( -50, 50 );
95-
console.log( '%d - %d = %d', x, y, subf( x, y ) );
96-
}
92+
logEachMap( '%d - %d = %d', x, y, subf );
9793
```
9894

9995
</section>

lib/node_modules/@stdlib/number/float32/base/sub/examples/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818

1919
'use strict';
2020

21-
var rand = require( '@stdlib/random/base/discrete-uniform' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var subf = require( './../lib' );
2324

24-
var x;
25-
var y;
26-
var i;
25+
var x = discreteUniform( 100, -50, 50 );
26+
var y = discreteUniform( 100, -50, 50 );
2727

28-
for ( i = 0; i < 100; i++ ) {
29-
x = rand( -50, 50 );
30-
y = rand( -50, 50 );
31-
console.log( '%d - %d = %d', x, y, subf( x, y ) );
32-
}
28+
logEachMap( '%d - %d = %d', x, y, subf );

0 commit comments

Comments
 (0)