1 | const Benchmark = require('benchmark')
|
2 | const suite = new Benchmark.Suite()
|
3 |
|
4 | const patrun = require('patrun')({ gex: true })
|
5 | const bloomrun = require('.')()
|
6 |
|
7 | patrun.add({ role: 'test', action: 'other', id: '*' }, 'result')
|
8 | bloomrun.add({ role: 'test', action: 'other', id: /.*/ }, 'result')
|
9 |
|
10 | suite.add('patrun#add', () => {
|
11 | patrun.add({test: 'pattern'}, 'test pattern')
|
12 | })
|
13 | suite.add('bloomrun#add', () => {
|
14 | bloomrun.add({test: 'pattern'}, 'test pattern')
|
15 | })
|
16 |
|
17 | suite.add('patrun#find', () => {
|
18 | patrun.find({ role: 'test', action: 'other', id: 'qwe', payload: { qwe: 'asd', zxc: 'xxx' } })
|
19 | })
|
20 |
|
21 | suite.add('bloomrun#lookup', () => {
|
22 | bloomrun.lookup({ role: 'test', action: 'other', id: 'qwe', payload: { qwe: 'asd', zxc: 'xxx' } })
|
23 | })
|
24 |
|
25 | suite.add('bloomrun#list', () => {
|
26 | bloomrun.lookup({ role: 'test', action: 'other', id: 'qwe', payload: { qwe: 'asd', zxc: 'xxx' } })
|
27 | })
|
28 |
|
29 | suite.on('cycle', event => console.log(String(event.target))).run()
|