-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.js
More file actions
42 lines (40 loc) · 1.3 KB
/
benchmark.js
File metadata and controls
42 lines (40 loc) · 1.3 KB
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
var Benchmark = require('benchmark')
var Suite = new Benchmark.Suite()
var filter = require('./index.js')
var data = [
{ type: 1, title: 'foo-1-1' },
{ type: 1, title: 'foo-1-2' },
{ type: 1, title: 'foo-1-3' },
{ type: 2, title: 'foo-2-1' },
{ type: 2, title: 'foo-2-2' },
{ type: 3, title: 'foo-3-1' },
{ type: 3, title: 'foo-3-2' },
{ type: 3, title: 'foo-3-3' },
{ type: 4, title: 'foo-4-1' },
{ type: 5, title: 'foo-5-1' }
]
Suite
.add('10x array / 1x bucket', function () {
filter(data, [
{ condition: function (i) { return i.type === 1 }, limit: 2 }
])
})
.add('10x array / 2x buckets', function () {
filter(data, [
{ condition: function (i) { return i.type === 1 }, limit: 2 },
{ condition: function (i) { return i.type === 1 }, limit: 3 }
])
})
.add('10x array / 5x buckets', function () {
filter(data, [
{ condition: function (i) { return i.type === 1 }, limit: 2 },
{ condition: function (i) { return i.type === 2 }, limit: 2 },
{ condition: function (i) { return i.type === 3 }, limit: 1 },
{ condition: function (i) { return i.type === 4 }, limit: 2 },
{ condition: function (i) { return i.type === 5 }, limit: 1 }
])
})
.on('cycle', function (e) {
console.log(String(e.target))
})
.run({ async: true })