Skip to content

Commit 21a679a

Browse files
committed
benchmark: add url benchmarks
Based on the ad-hoc benchmark from nodejs/node-v0.x-archive#8638 plus an additional benchmark for user:pass auth URLs. PR-URL: #102 Reviewed-by: Chris Dickinson <[email protected]>
1 parent ddf17f9 commit 21a679a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

benchmark/url/url.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var common = require('../common.js');
2+
var url = require('url');
3+
4+
var bench = common.createBenchmark(main, {
5+
type: 'one two three four five six'.split(' '),
6+
n: [25e4]
7+
});
8+
9+
function main(conf) {
10+
var type = conf.type;
11+
var n = conf.n | 0;
12+
13+
var inputs = {
14+
one: 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
15+
two: 'http://blog.nodejs.org/',
16+
three: 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
17+
four: 'javascript:alert("node is awesome");',
18+
five: 'some.ran/dom/url.thing?oh=yes#whoo',
19+
six: 'https://user:[email protected]/',
20+
};
21+
var input = inputs[type] || '';
22+
23+
bench.start();
24+
for (var i = 0; i < n; i += 1)
25+
url.parse(input);
26+
bench.end(n);
27+
}

0 commit comments

Comments
 (0)