UNPKG

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