-
Notifications
You must be signed in to change notification settings - Fork 84
/
benchmark.js
52 lines (49 loc) · 1.08 KB
/
benchmark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var Benchpress = require('@mariocasciaro/benchpress')
var benchmark = new Benchpress()
var op = require('./')
var testObj = {
level1_a: {
level2_a: {
level3_a: {
level4_a: {
}
}
}
}
}
var testObj2
benchmark
.add('get existing', {
iterations: 100000,
fn: function() {
op.get(testObj, ['level1_a', 'level2_a', 'level3_a', 'level4_a'])
}
})
.add('get non-existing', {
iterations: 100000,
fn: function() {
op.get(testObj, ['level5_a'])
}
})
.add('push', {
iterations: 100000,
fn: function() {
op.push(testObj, ['level1_a', 'level2_a', 'level3_a', 'level4_a', 'level5_a'], 'val')
}
})
.add('set non existing', {
iterations: 100000,
fn: function() {
op.set(testObj2, ['level1_a', 'level2_b', 'level3_b', 'level4_b', 'level5_b'], 'val')
},
beforeEach: function() {
testObj2 = {}
}
})
.add('set existing', {
iterations: 100000,
fn: function() {
op.set(testObj, ['level1_a', 'level2_a', 'level3_a', 'level4_a', 'level5_b'], 'val')
}
})
.run()