Skip to content

Commit 25b2056

Browse files
committed
refactor benchmarks/
1 parent 97bac79 commit 25b2056

File tree

5 files changed

+33
-53
lines changed

5 files changed

+33
-53
lines changed

lib/node_modules/@stdlib/blas/base/sdot/benchmark/benchmark.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,14 +21,19 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' ).factory;
25+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var pow = require( '@stdlib/math/base/special/pow' );
27-
var Float32Array = require( '@stdlib/array/float32' );
2828
var pkg = require( './../package.json' ).name;
2929
var sdot = require( './../lib/sdot.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var rand = uniform( -100.0, 100.0 );
35+
36+
3237
// FUNCTIONS //
3338

3439
/**
@@ -39,16 +44,8 @@ var sdot = require( './../lib/sdot.js' );
3944
* @returns {Function} benchmark function
4045
*/
4146
function createBenchmark( len ) {
42-
var x;
43-
var y;
44-
var i;
45-
46-
x = new Float32Array( len );
47-
y = new Float32Array( len );
48-
for ( i = 0; i < x.length; i++ ) {
49-
x[ i ] = ( randu()*20.0 ) - 10.0;
50-
y[ i ] = ( randu()*20.0 ) - 10.0;
51-
}
47+
var x = filledarrayBy( len, 'float32', rand );
48+
var y = filledarrayBy( len, 'float32', rand );
5249
return benchmark;
5350

5451
function benchmark( b ) {

lib/node_modules/@stdlib/blas/base/sdot/benchmark/benchmark.native.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@
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/base/uniform' ).factory;
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var pow = require( '@stdlib/math/base/special/pow' );
28-
var Float32Array = require( '@stdlib/array/float32' );
2929
var tryRequire = require( '@stdlib/utils/try-require' );
3030
var pkg = require( './../package.json' ).name;
3131

@@ -36,6 +36,7 @@ var sdot = tryRequire( resolve( __dirname, './../lib/sdot.native.js' ) );
3636
var opts = {
3737
'skip': ( sdot instanceof Error )
3838
};
39+
var rand = uniform( -100.0, 100.0 );
3940

4041

4142
// FUNCTIONS //
@@ -48,16 +49,8 @@ var opts = {
4849
* @returns {Function} benchmark function
4950
*/
5051
function createBenchmark( len ) {
51-
var x;
52-
var y;
53-
var i;
54-
55-
x = new Float32Array( len );
56-
y = new Float32Array( len );
57-
for ( i = 0; i < x.length; i++ ) {
58-
x[ i ] = ( randu()*20.0 ) - 10.0;
59-
y[ i ] = ( randu()*20.0 ) - 10.0;
60-
}
52+
var x = filledarrayBy( len, 'float32', rand );
53+
var y = filledarrayBy( len, 'float32', rand );
6154
return benchmark;
6255

6356
function benchmark( b ) {

lib/node_modules/@stdlib/blas/base/sdot/benchmark/benchmark.ndarray.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,14 +21,19 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' ).factory;
25+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var pow = require( '@stdlib/math/base/special/pow' );
27-
var Float32Array = require( '@stdlib/array/float32' );
2828
var pkg = require( './../package.json' ).name;
2929
var sdot = require( './../lib/ndarray.js' );
3030

3131

32+
// VARIABLES //
33+
34+
var rand = uniform( -100.0, 100.0 );
35+
36+
3237
// FUNCTIONS //
3338

3439
/**
@@ -39,16 +44,8 @@ var sdot = require( './../lib/ndarray.js' );
3944
* @returns {Function} benchmark function
4045
*/
4146
function createBenchmark( len ) {
42-
var x;
43-
var y;
44-
var i;
45-
46-
x = new Float32Array( len );
47-
y = new Float32Array( len );
48-
for ( i = 0; i < x.length; i++ ) {
49-
x[ i ] = ( randu()*20.0 ) - 10.0;
50-
y[ i ] = ( randu()*20.0 ) - 10.0;
51-
}
47+
var x = filledarrayBy( len, 'float32', rand );
48+
var y = filledarrayBy( len, 'float32', rand );
5249
return benchmark;
5350

5451
function benchmark( b ) {

lib/node_modules/@stdlib/blas/base/sdot/benchmark/benchmark.ndarray.native.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@
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/base/uniform' ).factory;
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2728
var pow = require( '@stdlib/math/base/special/pow' );
28-
var Float32Array = require( '@stdlib/array/float32' );
2929
var tryRequire = require( '@stdlib/utils/try-require' );
3030
var pkg = require( './../package.json' ).name;
3131

@@ -36,6 +36,7 @@ var sdot = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
3636
var opts = {
3737
'skip': ( sdot instanceof Error )
3838
};
39+
var rand = uniform( -100.0, 100.0 );
3940

4041

4142
// FUNCTIONS //
@@ -48,16 +49,8 @@ var opts = {
4849
* @returns {Function} benchmark function
4950
*/
5051
function createBenchmark( len ) {
51-
var x;
52-
var y;
53-
var i;
54-
55-
x = new Float32Array( len );
56-
y = new Float32Array( len );
57-
for ( i = 0; i < x.length; i++ ) {
58-
x[ i ] = ( randu()*20.0 ) - 10.0;
59-
y[ i ] = ( randu()*20.0 ) - 10.0;
60-
}
52+
var x = filledarrayBy( len, 'float32', rand );
53+
var y = filledarrayBy( len, 'float32', rand );
6154
return benchmark;
6255

6356
function benchmark( b ) {

lib/node_modules/@stdlib/blas/base/sdot/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2023 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)