@@ -42,7 +42,7 @@ var bternary3d = require( './../lib' );
42
42
* @param {PositiveIntegerArray } shape - output array shape
43
43
* @returns {Function } benchmark function
44
44
*/
45
- function createBenchmark ( shape ) {
45
+ function createBenchmark ( shape ) {
46
46
var arrays ;
47
47
var shapes ;
48
48
var x ;
@@ -51,17 +51,17 @@ function createBenchmark(shape) {
51
51
var w ;
52
52
53
53
shapes = [
54
- [ 1 , 1 , shape [ 2 ] ] ,
55
- [ shape [ 0 ] , 1 , 1 ] ,
56
- [ 1 , shape [ 1 ] , 1 ] ,
54
+ [ 1 , 1 , shape [ 2 ] ] ,
55
+ [ shape [ 0 ] , 1 , 1 ] ,
56
+ [ 1 , shape [ 1 ] , 1 ] ,
57
57
shape
58
58
] ;
59
- x = filled3dBy ( shapes [ 0 ] , uniform ( - 100.0 , 100.0 ) ) ;
60
- y = filled3dBy ( shapes [ 1 ] , uniform ( - 100.0 , 100.0 ) ) ;
61
- z = filled3dBy ( shapes [ 2 ] , uniform ( - 100.0 , 100.0 ) ) ;
62
- w = zeros3d ( shapes [ 3 ] ) ;
59
+ x = filled3dBy ( shapes [ 0 ] , uniform ( - 100.0 , 100.0 ) ) ;
60
+ y = filled3dBy ( shapes [ 1 ] , uniform ( - 100.0 , 100.0 ) ) ;
61
+ z = filled3dBy ( shapes [ 2 ] , uniform ( - 100.0 , 100.0 ) ) ;
62
+ w = zeros3d ( shapes [ 3 ] ) ;
63
63
64
- arrays = [ x , y , z , w ] ;
64
+ arrays = [ x , y , z , w ] ;
65
65
66
66
return benchmark ;
67
67
@@ -71,31 +71,31 @@ function createBenchmark(shape) {
71
71
* @private
72
72
* @param {Benchmark } b - benchmark instance
73
73
*/
74
- function benchmark ( b ) {
74
+ function benchmark ( b ) {
75
75
var i0 ;
76
76
var i1 ;
77
77
var i2 ;
78
78
var i ;
79
79
80
80
b . tic ( ) ;
81
- for ( i = 0 ; i < b . iterations ; i ++ ) {
82
- bternary3d ( arrays , shapes , add ) ;
83
- i2 = i % shapes [ 1 ] [ 0 ] ;
84
- i1 = i % shapes [ 1 ] [ 1 ] ;
85
- i0 = i % shapes [ 1 ] [ 2 ] ;
86
- if ( isnan ( arrays [ 3 ] [ i2 ] [ i1 ] [ i0 ] ) ) {
87
- b . fail ( 'should not return NaN' ) ;
81
+ for ( i = 0 ; i < b . iterations ; i ++ ) {
82
+ bternary3d ( arrays , shapes , add ) ;
83
+ i2 = i % shapes [ 1 ] [ 0 ] ;
84
+ i1 = i % shapes [ 1 ] [ 1 ] ;
85
+ i0 = i % shapes [ 1 ] [ 2 ] ;
86
+ if ( isnan ( arrays [ 3 ] [ i2 ] [ i1 ] [ i0 ] ) ) {
87
+ b . fail ( 'should not return NaN' ) ;
88
88
}
89
89
}
90
90
b . toc ( ) ;
91
91
92
- i2 = i % shapes [ 1 ] [ 0 ] ;
93
- i1 = i % shapes [ 1 ] [ 1 ] ;
94
- i0 = i % shapes [ 1 ] [ 2 ] ;
95
- if ( isnan ( arrays [ 3 ] [ i2 ] [ i1 ] [ i0 ] ) ) {
96
- b . fail ( 'should not return NaN' ) ;
92
+ i2 = i % shapes [ 1 ] [ 0 ] ;
93
+ i1 = i % shapes [ 1 ] [ 1 ] ;
94
+ i0 = i % shapes [ 1 ] [ 2 ] ;
95
+ if ( isnan ( arrays [ 3 ] [ i2 ] [ i1 ] [ i0 ] ) ) {
96
+ b . fail ( 'should not return NaN' ) ;
97
97
}
98
- b . pass ( 'benchmark finished' ) ;
98
+ b . pass ( 'benchmark finished' ) ;
99
99
b . end ( ) ;
100
100
}
101
101
}
@@ -119,11 +119,11 @@ function main() {
119
119
min = 1 ; // 10^min
120
120
max = 6 ; // 10^max
121
121
122
- for ( i = min ; i <= max ; i ++ ) {
123
- N = floor ( pow ( pow ( 10 , i ) , 1.0 / 3.0 ) ) ;
124
- sh = [ N , N , N ] ;
125
- f = createBenchmark ( sh ) ;
126
- bench ( pkg + '::equidimensional:size=' + numel ( sh ) , f ) ;
122
+ for ( i = min ; i <= max ; i ++ ) {
123
+ N = floor ( pow ( pow ( 10 , i ) , 1.0 / 3.0 ) ) ;
124
+ sh = [ N , N , N ] ;
125
+ f = createBenchmark ( sh ) ;
126
+ bench ( pkg + '::equidimensional:size=' + numel ( sh ) , f ) ;
127
127
}
128
128
}
129
129
0 commit comments