Skip to content

Commit 7a3553f

Browse files
joyeecheungitaloacasas
authored andcommitted
benchmark: move url data to fixtures
PR-URL: #11264 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 348f2ef commit 7a3553f

6 files changed

+35
-63
lines changed

benchmark/fixtures/url-inputs.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
exports.urls = {
4+
long: 'http://nodejs.org:89/docs/latest/api/foo/bar/qua/13949281/0f28b/' +
5+
'/5d49/b3020/url.html#test?payload1=true&payload2=false&test=1' +
6+
'&benchmark=3&foo=38.38.011.293&bar=1234834910480&test=19299&3992&' +
7+
'key=f5c65e1e98fe07e648249ad41e1cfdb0',
8+
short: 'https://nodejs.org/en/blog/',
9+
idn: 'http://你好你好.在线',
10+
auth: 'https://user:[email protected]/path?search=1',
11+
file: 'file:///foo/bar/test/node.js',
12+
ws: 'ws://localhost:9229/f46db715-70df-43ad-a359-7f9949f39868',
13+
javascript: 'javascript:alert("node is awesome");',
14+
percent: 'https://%E4%BD%A0/foo',
15+
dot: 'https://example.org/./a/../b/./c'
16+
};
17+
18+
exports.searchParams = {
19+
noencode: 'foo=bar&baz=quux&xyzzy=thud',
20+
multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud',
21+
encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud',
22+
encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
23+
encodelast: 'foo=bar&baz=quux&xyzzy=thu%64',
24+
multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz',
25+
multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' +
26+
'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz',
27+
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',
28+
manyblankpairs: '&&&&&&&&&&&&&&&&&&&&&&&&',
29+
altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi'
30+
};

benchmark/url/legacy-vs-whatwg-url-get-prop.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@ const common = require('../common.js');
33
const url = require('url');
44
const URL = url.URL;
55
const assert = require('assert');
6-
7-
const inputs = {
8-
long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' +
9-
'payload1=true&payload2=false&test=1&benchmark=3&' +
10-
'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' +
11-
'key=f5c65e1e98fe07e648249ad41e1cfdb0',
12-
short: 'https://nodejs.org/en/blog/',
13-
idn: 'http://你好你好',
14-
auth: 'https://user:[email protected]/path?search=1',
15-
special: 'file:///foo/bar/test/node.js',
16-
percent: 'https://%E4%BD%A0/foo',
17-
dot: 'https://example.org/./a/../b/./c'
18-
};
6+
const inputs = require('../fixtures/url-inputs.js').urls;
197

208
const bench = common.createBenchmark(main, {
219
type: Object.keys(inputs),

benchmark/url/legacy-vs-whatwg-url-parse.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@ const common = require('../common.js');
33
const url = require('url');
44
const URL = url.URL;
55
const assert = require('assert');
6-
7-
const inputs = {
8-
long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' +
9-
'payload1=true&payload2=false&test=1&benchmark=3&' +
10-
'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' +
11-
'key=f5c65e1e98fe07e648249ad41e1cfdb0',
12-
short: 'https://nodejs.org/en/blog/',
13-
idn: 'http://你好你好',
14-
auth: 'https://user:[email protected]/path?search=1',
15-
special: 'file:///foo/bar/test/node.js',
16-
percent: 'https://%E4%BD%A0/foo',
17-
dot: 'https://example.org/./a/../b/./c'
18-
};
6+
const inputs = require('../fixtures/url-inputs.js').urls;
197

208
const bench = common.createBenchmark(main, {
219
type: Object.keys(inputs),

benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
const common = require('../common.js');
33
const { URLSearchParams } = require('url');
44
const querystring = require('querystring');
5-
6-
const inputs = {
7-
noencode: 'foo=bar&baz=quux&xyzzy=thud',
8-
encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
9-
encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud',
10-
encodelast: 'foo=bar&baz=quux&xyzzy=thu%64',
11-
multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud',
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-
};
5+
const inputs = require('../fixtures/url-inputs.js').searchParams;
176

187
const bench = common.createBenchmark(main, {
198
type: Object.keys(inputs),

benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
const common = require('../common.js');
33
const { URLSearchParams } = require('url');
44
const querystring = require('querystring');
5-
6-
const inputs = {
7-
noencode: 'foo=bar&baz=quux&xyzzy=thud',
8-
encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d',
9-
encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud',
10-
encodelast: 'foo=bar&baz=quux&xyzzy=thu%64',
11-
multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud',
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-
};
5+
const inputs = require('../fixtures/url-inputs.js').searchParams;
176

187
const bench = common.createBenchmark(main, {
198
type: Object.keys(inputs),

benchmark/url/legacy-vs-whatwg-url-serialize.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@ const common = require('../common.js');
33
const url = require('url');
44
const URL = url.URL;
55
const assert = require('assert');
6-
7-
const inputs = {
8-
long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' +
9-
'payload1=true&payload2=false&test=1&benchmark=3&' +
10-
'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' +
11-
'key=f5c65e1e98fe07e648249ad41e1cfdb0',
12-
short: 'https://nodejs.org/en/blog/',
13-
idn: 'http://你好你好',
14-
auth: 'https://user:[email protected]/path?search=1',
15-
special: 'file:///foo/bar/test/node.js',
16-
percent: 'https://%E4%BD%A0/foo',
17-
dot: 'https://example.org/./a/../b/./c'
18-
};
6+
const inputs = require('../fixtures/url-inputs.js').urls;
197

208
const bench = common.createBenchmark(main, {
219
type: Object.keys(inputs),

0 commit comments

Comments
 (0)