-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbenchmark.js
More file actions
34 lines (30 loc) · 732 Bytes
/
Copy pathbenchmark.js
File metadata and controls
34 lines (30 loc) · 732 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
33
34
/**
* Created by hustcc.
* Contract: i@hust.cc
*/
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite();
var URI = require('./');
var URL = require('url-parse');
var u = 'scheme://username:password@host:port/path?name=hustcc#fragment;ext=hello';
suite
.add('URI', function () {
new URI(u);
})
.add('URL', function () {
URL(u, true);
})
.on('cycle', function (e) {
console.log('' + e.target);
})
.on('complete', function() {
var fast = this.filter('fastest');
var slow = this.filter('slowest');
console.log('[OPS] ' +
fast.map('name') + ' / ' + slow.map('name') +
' = ' +
(fast.map('hz') / slow.map('hz')).toFixed(3) +
'\n'
);
})
.run();