-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.js
More file actions
32 lines (28 loc) · 844 Bytes
/
benchmark.js
File metadata and controls
32 lines (28 loc) · 844 Bytes
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
'use strict'
const benchmark = require('benchmark')
const { URL, parse } = require('url')
const urlParser = require('.')
const { URL: NURL } = urlParser
const suite = new benchmark.Suite()
const testUrl = 'http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content'
suite
.add('WHATWG URL', () => {
return new URL(testUrl)
})
.add('Nodejs url.parse', () => {
parse(testUrl)
})
.add('urlParser from jQuery Mobile', () => {
urlParser(testUrl)
})
.add('urlParser in WHATWG URL way', () => {
return new NURL(testUrl)
})
.on('cycle', (event) => {
console.log(String(event.target))
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'))
console.log('Slowest is ' + this.filter('slowest').map('name'))
})
.run({maxTime: 10})