Skip to content

Commit 34611bf

Browse files
committed
Update benchmarks
1 parent 46bc91b commit 34611bf

File tree

6 files changed

+84
-150
lines changed

6 files changed

+84
-150
lines changed

lib/node_modules/@stdlib/utils/deep-get/benchmark/bechmark.factory.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/node_modules/@stdlib/utils/deep-get/benchmark/benchmark.js

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var deepGet = require( './../lib' );
3030
// MAIN //
3131

3232
bench( pkg, function benchmark( b ) {
33+
var arr;
3334
var obj;
3435
var out;
3536
var i;
@@ -38,14 +39,15 @@ bench( pkg, function benchmark( b ) {
3839
'a': {
3940
'b': {
4041
'c': {
41-
'd': [ 0, 0.5, 1 ]
42+
'd': [ 0.0, 0.5, 1.0 ]
4243
}
4344
}
4445
}
4546
};
47+
arr = obj.a.b.c.d;
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
obj.a.b.c.d[ 1 ] = randu();
50+
arr[ 1 ] = randu();
4951
out = deepGet( obj, 'a.b.c.d' );
5052
if ( typeof out !== 'object' ) {
5153
b.fail( 'should return an array' );
@@ -61,6 +63,7 @@ bench( pkg, function benchmark( b ) {
6163

6264
bench( pkg+'::paths_array', function benchmark( b ) {
6365
var paths;
66+
var arr;
6467
var obj;
6568
var out;
6669
var i;
@@ -69,15 +72,16 @@ bench( pkg+'::paths_array', function benchmark( b ) {
6972
'a': {
7073
'b': {
7174
'c': {
72-
'd': [ 0, 0.5, 1 ]
75+
'd': [ 0.0, 0.5, 1.0 ]
7376
}
7477
}
7578
}
7679
};
7780
paths = [ 'a', 'b', 'c', 'd' ];
81+
arr = obj.a.b.c.d;
7882
b.tic();
7983
for ( i = 0; i < b.iterations; i++ ) {
80-
obj.a.b.c.d[ 1 ] = randu();
84+
arr[ 1 ] = randu();
8185
out = deepGet( obj, paths );
8286
if ( typeof out !== 'object' ) {
8387
b.fail( 'should return an array' );
@@ -90,3 +94,37 @@ bench( pkg+'::paths_array', function benchmark( b ) {
9094
b.pass( 'benchmark finished' );
9195
b.end();
9296
});
97+
98+
bench( pkg+':factory', function benchmark( b ) {
99+
var dget;
100+
var arr;
101+
var obj;
102+
var out;
103+
var i;
104+
105+
obj = {
106+
'a': {
107+
'b': {
108+
'c': {
109+
'd': [ 0.0, 0.5, 1.0 ]
110+
}
111+
}
112+
}
113+
};
114+
dget = deepGet.factory( 'a.b.c.d' );
115+
arr = obj.a.b.c.d;
116+
b.tic();
117+
for ( i = 0; i < b.iterations; i++ ) {
118+
arr[ 1 ] = randu();
119+
out = dget( obj );
120+
if ( typeof out !== 'object' ) {
121+
b.fail( 'should return an array' );
122+
}
123+
}
124+
b.toc();
125+
if ( !isArray( out ) ) {
126+
b.fail( 'should return an array' );
127+
}
128+
b.pass( 'benchmark finished' );
129+
b.end();
130+
});

lib/node_modules/@stdlib/utils/deep-pluck/benchmark/benchmark.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
var bench = require( '@stdlib/bench' );
2424
var isArray = require( '@stdlib/assert/is-array' );
2525
var randu = require( '@stdlib/random/base/randu' );
26-
var round = require( '@stdlib/math/base/special/round' );
2726
var pkg = require( './../package.json' ).name;
2827
var deepPluck = require( './../lib' );
2928

@@ -42,17 +41,16 @@ bench( pkg, function benchmark( b ) {
4241
'a': {
4342
'b': {
4443
'c': {
45-
'd': null
44+
'd': randu()
4645
}
4746
}
4847
}
4948
};
50-
tmp.a.b.c.d = round( randu()*100.0 );
5149
arr[ i ] = tmp;
5250
}
5351
b.tic();
5452
for ( i = 0; i < b.iterations; i++ ) {
55-
arr[ i % arr.length ].a.b.c.d = randu();
53+
arr[ 0 ].a.b.c.d = randu();
5654
out = deepPluck( arr, 'a.b.c.d' );
5755
if ( typeof out !== 'object' ) {
5856
b.fail( 'should return an array' );

lib/node_modules/@stdlib/utils/deep-set/benchmark/bechmark.factory.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

lib/node_modules/@stdlib/utils/deep-set/benchmark/benchmark.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ var deepSet = require( './../lib' );
2828

2929
// FUNCTIONS //
3030

31-
function set() {
31+
function set1() {
3232
return randu();
3333
}
3434

35+
function set2( val ) {
36+
return val * 1.5;
37+
}
38+
3539

3640
// MAIN //
3741

@@ -57,9 +61,6 @@ bench( pkg, function benchmark( b ) {
5761
if ( bool !== true ) {
5862
b.fail( 'should return true' );
5963
}
60-
if ( val !== obj.a.b.c.d ) {
61-
b.fail( 'should succesfully set property value' );
62-
}
6364
}
6465
b.toc();
6566
if ( bool !== true ) {
@@ -88,12 +89,43 @@ bench( pkg+'::setter', function benchmark( b ) {
8889
};
8990
b.tic();
9091
for ( i = 0; i < b.iterations; i++ ) {
91-
bool = deepSet( obj, 'a.b.c.d', set );
92+
bool = deepSet( obj, 'a.b.c.d', set1 );
9293
if ( bool !== true ) {
9394
b.fail( 'should return true' );
9495
}
95-
if ( obj.a.b.c.d !== obj.a.b.c.d ) {
96-
b.fail( 'should succesfully set property value' );
96+
}
97+
b.toc();
98+
if ( bool !== true ) {
99+
b.fail( 'should return true' );
100+
}
101+
if ( obj.a.b.c.d !== obj.a.b.c.d ) {
102+
b.fail( 'should succesfully set property value' );
103+
}
104+
b.pass( 'benchmark finished' );
105+
b.end();
106+
});
107+
108+
bench( pkg+':factory', function benchmark( b ) {
109+
var bool;
110+
var dset;
111+
var obj;
112+
var i;
113+
114+
obj = {
115+
'a': {
116+
'b': {
117+
'c': {
118+
'd': 0.5
119+
}
120+
}
121+
}
122+
};
123+
dset = deepSet.factory( 'a.b.c.d' );
124+
b.tic();
125+
for ( i = 0; i < b.iterations; i++ ) {
126+
bool = dset( obj, set2 );
127+
if ( bool !== true ) {
128+
b.fail( 'should return true' );
97129
}
98130
}
99131
b.toc();

lib/node_modules/@stdlib/utils/memoize/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bench( pkg, function benchmark( b ) {
5757
b.end();
5858
});
5959

60-
bench( pkg+'::memoized_function', function benchmark( b ) {
60+
bench( pkg+'::returned_function', function benchmark( b ) {
6161
var fcn;
6262
var out;
6363
var x;

0 commit comments

Comments
 (0)