Skip to content

Commit aa47fe0

Browse files
BridgeARevanlucas
authored andcommitted
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 1 addition & 5 deletions
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

Lines changed: 2 additions & 3 deletions
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

0 commit comments

Comments
 (0)