Skip to content

Commit 5a81031

Browse files
joyeecheungitaloacasas
authored andcommitted
benchmark: clean up legacy url benchmarks
Backport-of: #11264
1 parent 8dbd562 commit 5a81031

File tree

4 files changed

+23
-77
lines changed

4 files changed

+23
-77
lines changed

benchmark/querystring/querystring-parse.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@ var common = require('../common.js');
33
var querystring = require('querystring');
44
var v8 = require('v8');
55

6-
var inputs = {
7-
noencode: 'foo=bar&baz=quux&xyzzy=thud',
8-
multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud',
9-
encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud',
10-
encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
11-
encodelast: 'foo=bar&baz=quux&xyzzy=thu%64',
12-
multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz',
13-
multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' +
14-
'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz',
15-
manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z'
16-
};
6+
var inputs = require('../fixtures/url-inputs.js').searchParams;
177

188
var bench = common.createBenchmark(main, {
199
type: Object.keys(inputs),

benchmark/url/url-format.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@ const common = require('../common.js');
33
const url = require('url');
44
const v8 = require('v8');
55

6+
const inputs = {
7+
slashes: {slashes: true, host: 'localhost'},
8+
file: {protocol: 'file:', pathname: '/foo'},
9+
};
10+
611
const bench = common.createBenchmark(main, {
7-
type: 'one two'.split(' '),
12+
type: Object.keys(inputs),
813
n: [25e6]
914
});
1015

1116
function main(conf) {
1217
const type = conf.type;
1318
const n = conf.n | 0;
1419

15-
const inputs = {
16-
one: {slashes: true, host: 'localhost'},
17-
two: {protocol: 'file:', pathname: '/foo'},
18-
};
1920
const input = inputs[type] || '';
2021

2122
// Force-optimize url.format() so that the benchmark doesn't get

benchmark/url/url-parse.js

-37
This file was deleted.

benchmark/url/url-resolve.js

+16-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
'use strict';
2-
var common = require('../common.js');
3-
var url = require('url');
4-
var v8 = require('v8');
2+
const common = require('../common.js');
3+
const url = require('url');
4+
const v8 = require('v8');
5+
const hrefs = require('../fixtures/url-inputs.js').urls;
6+
hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo';
57

6-
var hrefs = [
7-
'http://example.com/',
8-
'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj',
9-
'http://blog.nodejs.org/',
10-
'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en',
11-
'javascript:alert("node is awesome");',
12-
'some.ran/dom/url.thing?oh=yes#whoo'
13-
];
8+
const paths = {
9+
'up': '../../../../../etc/passwd',
10+
'sibling': '../foo/bar?baz=boom',
11+
'foo/bar': 'foo/bar',
12+
'withscheme': 'http://nodejs.org',
13+
'down': './foo/bar?baz'
14+
};
1415

15-
16-
var paths = [
17-
'../../../../../etc/passwd',
18-
'../foo/bar?baz=boom',
19-
'foo/bar',
20-
'http://nodejs.org',
21-
'./foo/bar?baz'
22-
];
23-
24-
var bench = common.createBenchmark(main, {
16+
const bench = common.createBenchmark(main, {
2517
href: Object.keys(hrefs),
2618
path: Object.keys(paths),
2719
n: [1e5]
2820
});
2921

3022
function main(conf) {
31-
var n = conf.n | 0;
32-
var href = hrefs[conf.href];
33-
var path = paths[conf.path];
23+
const n = conf.n | 0;
24+
const href = hrefs[conf.href];
25+
const path = paths[conf.path];
3426

3527
// Force-optimize url.resolve() so that the benchmark doesn't get
3628
// disrupted by the optimizer kicking in halfway through.

0 commit comments

Comments
 (0)