-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsimple.js
62 lines (51 loc) · 1.14 KB
/
simple.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
53
54
55
56
57
58
59
60
61
62
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var BEMPRIV = require('../');
BEMPRIV.decl('testCreate');
BEMPRIV.decl('testStatic', {}, {
bemjson: function() {
return {
block: 'test'
}
}
});
BEMPRIV.decl('testHelper');
var blocks = {};
blocks['object'] = {
bemjson: function() {
return {
block: 'test'
}
}
}
blocks['plain'] = function() {
return {
block: 'test'
}
};
// add tests
suite
.add('BEMPRIV.create', function() {
BEMPRIV.create('testCreate').json();
})
.add('BEMPRIV.static', function() {
BEMPRIV.blocks['testStatic'].bemjson();
})
.add('BEMPRIV.json', function() {
BEMPRIV.json('testHelper');
})
.add('Plain Object', function() {
blocks['object'].bemjson();
})
.add('Plain Function', function() {
blocks['plain']();
})
// add listeners
suite
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
});
suite.run();