Skip to content

Commit

Permalink
benchmark: (url) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent e00dac7 commit aa47fe0
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 59 deletions.
6 changes: 1 addition & 5 deletions benchmark/url/legacy-vs-whatwg-url-get-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ function useWHATWG(n, input) {
return noDead;
}

function main(conf) {
const type = conf.type;
const n = conf.n | 0;
const method = conf.method;

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error('Unknown input type');
Expand Down
6 changes: 1 addition & 5 deletions benchmark/url/legacy-vs-whatwg-url-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ function useWHATWG(n, input) {
return noDead;
}

function main(conf) {
const type = conf.type;
const n = conf.n | 0;
const method = conf.method;

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error('Unknown input type');
Expand Down
6 changes: 1 addition & 5 deletions benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ function useWHATWG(n, input) {
bench.end(n);
}

function main(conf) {
const type = conf.type;
const n = conf.n | 0;
const method = conf.method;

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error('Unknown input type');
Expand Down
6 changes: 1 addition & 5 deletions benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ function useWHATWG(n, input, prop) {
bench.end(n);
}

function main(conf) {
const type = conf.type;
const n = conf.n | 0;
const method = conf.method;

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error('Unknown input type');
Expand Down
6 changes: 1 addition & 5 deletions benchmark/url/legacy-vs-whatwg-url-serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ function useWHATWG(n, input, prop) {
return noDead;
}

function main(conf) {
const type = conf.type;
const n = conf.n | 0;
const method = conf.method;

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error('Unknown input type');
Expand Down
5 changes: 1 addition & 4 deletions benchmark/url/url-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const bench = common.createBenchmark(main, {
n: [25e6]
});

function main(conf) {
const type = conf.type;
const n = conf.n | 0;

function main({ type, n }) {
const input = inputs[type] || '';

// Force-optimize url.format() so that the benchmark doesn't get
Expand Down
9 changes: 4 additions & 5 deletions benchmark/url/url-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const bench = common.createBenchmark(main, {
n: [1e5]
});

function main(conf) {
const n = conf.n | 0;
const href = hrefs[conf.href];
const path = paths[conf.path];
function main({ n, href, path }) {
const h = hrefs[href];
const p = paths[path];

bench.start();
for (var i = 0; i < n; i += 1)
url.resolve(href, path);
url.resolve(h, p);
bench.end(n);
}
5 changes: 1 addition & 4 deletions benchmark/url/url-searchparams-iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ function iterator(n) {
assert.strictEqual(noDead[1], '3rd');
}

function main(conf) {
const method = conf.method;
const n = conf.n | 0;

function main({ method, n }) {
switch (method) {
case 'forEach':
forEach(n);
Expand Down
6 changes: 1 addition & 5 deletions benchmark/url/url-searchparams-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ function has(n, param) {
bench.end(n);
}

function main(conf) {
const method = conf.method;
const param = conf.param;
const n = conf.n | 0;

function main({ method, param, n }) {
switch (method) {
case 'get':
get(n, param);
Expand Down
5 changes: 2 additions & 3 deletions benchmark/url/url-searchparams-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});

function main(conf) {
function main({ type, n }) {
const searchParams = require('internal/url').searchParamsSymbol;
const input = inputs[conf.type];
const n = conf.n | 0;
const input = inputs[type];
const params = new URLSearchParams();
const array = getParams(input);

Expand Down
5 changes: 2 additions & 3 deletions benchmark/url/usvstring.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});

function main(conf) {
function main({ input, n }) {
const { toUSVString } = require('internal/url');
const str = inputs[conf.input];
const n = conf.n | 0;
const str = inputs[input];

bench.start();
for (var i = 0; i < n; i++)
Expand Down
8 changes: 3 additions & 5 deletions benchmark/url/whatwg-url-idna.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ const bench = common.createBenchmark(main, {
n: [5e6]
});

function main(conf) {
const n = conf.n | 0;
const to = conf.to;
const input = inputs[conf.input][to];
function main({ n, to, input }) {
const value = inputs[input][to];
const method = to === 'ascii' ? domainToASCII : domainToUnicode;

bench.start();
for (var i = 0; i < n; i++) {
method(input);
method(value);
}
bench.end(n);
}
8 changes: 3 additions & 5 deletions benchmark/url/whatwg-url-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ function getAlternative(prop) {
return alternatives[prop];
}

function main(conf) {
const n = conf.n | 0;
const input = inputs[conf.input];
const url = new URL(input);
const prop = conf.prop;
function main({ n, input, prop }) {
const value = inputs[input];
const url = new URL(value);

switch (prop) {
case 'protocol':
Expand Down

0 comments on commit aa47fe0

Please sign in to comment.