@@ -42,7 +42,7 @@ var bternary3d = require( './../lib' );
4242* @param {PositiveIntegerArray } shape - output array shape
4343* @returns {Function } benchmark function
4444*/
45- function createBenchmark ( shape ) {
45+ function createBenchmark ( shape ) {
4646 var arrays ;
4747 var shapes ;
4848 var x ;
@@ -51,17 +51,17 @@ function createBenchmark(shape) {
5151 var w ;
5252
5353 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 ] ,
5757 shape
5858 ] ;
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 ] ) ;
6363
64- arrays = [ x , y , z , w ] ;
64+ arrays = [ x , y , z , w ] ;
6565
6666 return benchmark ;
6767
@@ -71,31 +71,31 @@ function createBenchmark(shape) {
7171 * @private
7272 * @param {Benchmark } b - benchmark instance
7373 */
74- function benchmark ( b ) {
74+ function benchmark ( b ) {
7575 var i0 ;
7676 var i1 ;
7777 var i2 ;
7878 var i ;
7979
8080 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' ) ;
8888 }
8989 }
9090 b . toc ( ) ;
9191
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' ) ;
9797 }
98- b . pass ( 'benchmark finished' ) ;
98+ b . pass ( 'benchmark finished' ) ;
9999 b . end ( ) ;
100100 }
101101}
@@ -119,11 +119,11 @@ function main() {
119119 min = 1 ; // 10^min
120120 max = 6 ; // 10^max
121121
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 ) ;
127127 }
128128}
129129
0 commit comments