-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (28 loc) · 1.13 KB
/
index.js
File metadata and controls
35 lines (28 loc) · 1.13 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
'use strict';
/* eslint import/no-unresolved: 0 */
const Benchmark = require('benchmark');
const Route = require('route-parser');
const FnRoute = require('../src');
const compiledRoute = Route('my/fancy/route/page/:page');
const compiledFnRoute = FnRoute('my/fancy/route/page/:page');
const suite = new Benchmark.Suite();
// add tests
suite.add('route-parser#compile', () => Route('my/fancy/route/page/:page'))
.add('functional-route-parser#compile', () => FnRoute('my/fancy/route/page/:page'))
// add listeners
.on('cycle', event => console.log(String(event.target)))
.on('complete', function complete() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ async: true });
// add tests
suite.add('route-parser#match', () => compiledRoute.match('my/fancy/route/page/7'))
.add('functional-route-parser#match', () => compiledFnRoute.parse('my/fancy/route/page/7'))
// add listeners
.on('cycle', event => console.log(String(event.target)))
.on('complete', function complete() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ async: true });