Skip to content

Commit aa47fe0

Browse files
BridgeARevanlucas
authored andcommittedJan 30, 2018
benchmark: (url) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e00dac7 commit aa47fe0

13 files changed

+22
-59
lines changed
 

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ function useWHATWG(n, input) {
7171
return noDead;
7272
}
7373

74-
function main(conf) {
75-
const type = conf.type;
76-
const n = conf.n | 0;
77-
const method = conf.method;
78-
74+
function main({ type, n, method }) {
7975
const input = inputs[type];
8076
if (!input) {
8177
throw new Error('Unknown input type');

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ function useWHATWG(n, input) {
3131
return noDead;
3232
}
3333

34-
function main(conf) {
35-
const type = conf.type;
36-
const n = conf.n | 0;
37-
const method = conf.method;
38-
34+
function main({ type, n, method }) {
3935
const input = inputs[type];
4036
if (!input) {
4137
throw new Error('Unknown input type');

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ function useWHATWG(n, input) {
2828
bench.end(n);
2929
}
3030

31-
function main(conf) {
32-
const type = conf.type;
33-
const n = conf.n | 0;
34-
const method = conf.method;
35-
31+
function main({ type, n, method }) {
3632
const input = inputs[type];
3733
if (!input) {
3834
throw new Error('Unknown input type');

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ function useWHATWG(n, input, prop) {
3030
bench.end(n);
3131
}
3232

33-
function main(conf) {
34-
const type = conf.type;
35-
const n = conf.n | 0;
36-
const method = conf.method;
37-
33+
function main({ type, n, method }) {
3834
const input = inputs[type];
3935
if (!input) {
4036
throw new Error('Unknown input type');

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ function useWHATWG(n, input, prop) {
3333
return noDead;
3434
}
3535

36-
function main(conf) {
37-
const type = conf.type;
38-
const n = conf.n | 0;
39-
const method = conf.method;
40-
36+
function main({ type, n, method }) {
4137
const input = inputs[type];
4238
if (!input) {
4339
throw new Error('Unknown input type');

‎benchmark/url/url-format.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const bench = common.createBenchmark(main, {
1212
n: [25e6]
1313
});
1414

15-
function main(conf) {
16-
const type = conf.type;
17-
const n = conf.n | 0;
18-
15+
function main({ type, n }) {
1916
const input = inputs[type] || '';
2017

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

‎benchmark/url/url-resolve.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ const bench = common.createBenchmark(main, {
1818
n: [1e5]
1919
});
2020

21-
function main(conf) {
22-
const n = conf.n | 0;
23-
const href = hrefs[conf.href];
24-
const path = paths[conf.path];
21+
function main({ n, href, path }) {
22+
const h = hrefs[href];
23+
const p = paths[path];
2524

2625
bench.start();
2726
for (var i = 0; i < n; i += 1)
28-
url.resolve(href, path);
27+
url.resolve(h, p);
2928
bench.end(n);
3029
}

‎benchmark/url/url-searchparams-iteration.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ function iterator(n) {
4444
assert.strictEqual(noDead[1], '3rd');
4545
}
4646

47-
function main(conf) {
48-
const method = conf.method;
49-
const n = conf.n | 0;
50-
47+
function main({ method, n }) {
5148
switch (method) {
5249
case 'forEach':
5350
forEach(n);

‎benchmark/url/url-searchparams-read.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ function has(n, param) {
3737
bench.end(n);
3838
}
3939

40-
function main(conf) {
41-
const method = conf.method;
42-
const param = conf.param;
43-
const n = conf.n | 0;
44-
40+
function main({ method, param, n }) {
4541
switch (method) {
4642
case 'get':
4743
get(n, param);

‎benchmark/url/url-searchparams-sort.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ const bench = common.createBenchmark(main, {
3131
flags: ['--expose-internals']
3232
});
3333

34-
function main(conf) {
34+
function main({ type, n }) {
3535
const searchParams = require('internal/url').searchParamsSymbol;
36-
const input = inputs[conf.type];
37-
const n = conf.n | 0;
36+
const input = inputs[type];
3837
const params = new URLSearchParams();
3938
const array = getParams(input);
4039

‎benchmark/url/usvstring.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ const bench = common.createBenchmark(main, {
1616
flags: ['--expose-internals']
1717
});
1818

19-
function main(conf) {
19+
function main({ input, n }) {
2020
const { toUSVString } = require('internal/url');
21-
const str = inputs[conf.input];
22-
const n = conf.n | 0;
21+
const str = inputs[input];
2322

2423
bench.start();
2524
for (var i = 0; i < n; i++)

‎benchmark/url/whatwg-url-idna.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ const bench = common.createBenchmark(main, {
3131
n: [5e6]
3232
});
3333

34-
function main(conf) {
35-
const n = conf.n | 0;
36-
const to = conf.to;
37-
const input = inputs[conf.input][to];
34+
function main({ n, to, input }) {
35+
const value = inputs[input][to];
3836
const method = to === 'ascii' ? domainToASCII : domainToUnicode;
3937

4038
bench.start();
4139
for (var i = 0; i < n; i++) {
42-
method(input);
40+
method(value);
4341
}
4442
bench.end(n);
4543
}

‎benchmark/url/whatwg-url-properties.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ function getAlternative(prop) {
4646
return alternatives[prop];
4747
}
4848

49-
function main(conf) {
50-
const n = conf.n | 0;
51-
const input = inputs[conf.input];
52-
const url = new URL(input);
53-
const prop = conf.prop;
49+
function main({ n, input, prop }) {
50+
const value = inputs[input];
51+
const url = new URL(value);
5452

5553
switch (prop) {
5654
case 'protocol':

0 commit comments

Comments
 (0)
Please sign in to comment.