-
-
Notifications
You must be signed in to change notification settings - Fork 117
/
benchmark.js
40 lines (36 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
var Benchmark = require('benchmark'),
Baobab = require('./src/baobab.js');
var suite = new Benchmark.Suite();
var tree = new Baobab();
tree.set(['a', 'b', 'c', 'd', 'e', 'f', 'g'], []);
var cursor = tree.select(['a', 'b', 'c']);
suite
.add('Baobab#get', function() {
tree.get(['a', 'b', 'c', 'd']);
})
.add('Baobab#set', function() {
tree.set(['a', 'b', 'c', 'foo'], 'bar');
})
.add('Baobab#unset', function() {
tree.unset(['a', 'b', 'c', 'foo']);
})
.add('Baobab.Cursor#set', function() {
cursor.set({ d: { e: { f: { g: [] } } } });
cursor.set(['d', 'e', 'f', 'foo'], 'bar');
})
.add('Baobab.Cursor#unset', function() {
cursor.unset(['d', 'e', 'f', 'foo']);
})
.add('Baobab.Cursor#push', function() {
cursor.push(['d', 'e', 'f', 'g'], 'baobab');
})
.add('Baobab.Cursor#unshift', function() {
cursor.unshift(['d', 'e', 'f', 'g'], 'baobab');
})
.add('Baobab.Cursor#splice', function() {
cursor.splice(['d', 'e', 'f', 'g'], [1, 1, 'baobab']);
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.run();