diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js index 93603c258cf1f2..2cc3ab8c75e65c 100644 --- a/benchmark/url/legacy-vs-whatwg-url-get-prop.js +++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js @@ -74,7 +74,7 @@ function useWHATWG(n, input) { function main({ type, n, method }) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -86,7 +86,7 @@ function main({ type, n, method }) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method "${method}"`); } assert.ok(noDead); diff --git a/benchmark/url/legacy-vs-whatwg-url-parse.js b/benchmark/url/legacy-vs-whatwg-url-parse.js index da42d5a189af47..2be55e17cc354b 100644 --- a/benchmark/url/legacy-vs-whatwg-url-parse.js +++ b/benchmark/url/legacy-vs-whatwg-url-parse.js @@ -34,7 +34,7 @@ function useWHATWG(n, input) { function main({ type, n, method }) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -46,7 +46,7 @@ function main({ type, n, method }) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } assert.ok(noDead); diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js index 51953ec8707374..e915ceb54f917f 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js @@ -31,7 +31,7 @@ function useWHATWG(n, input) { function main({ type, n, method }) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } switch (method) { @@ -42,6 +42,6 @@ function main({ type, n, method }) { useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js index 3490782a1bf421..8fe3e546f0780d 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js @@ -33,7 +33,7 @@ function useWHATWG(n, input, prop) { function main({ type, n, method }) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } switch (method) { @@ -44,6 +44,6 @@ function main({ type, n, method }) { useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/legacy-vs-whatwg-url-serialize.js b/benchmark/url/legacy-vs-whatwg-url-serialize.js index e92b941b5d57e5..017ec4328c590b 100644 --- a/benchmark/url/legacy-vs-whatwg-url-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-serialize.js @@ -36,7 +36,7 @@ function useWHATWG(n, input, prop) { function main({ type, n, method }) { const input = inputs[type]; if (!input) { - throw new Error('Unknown input type'); + throw new Error(`Unknown input type "${type}"`); } var noDead; // Avoid dead code elimination. @@ -48,7 +48,7 @@ function main({ type, n, method }) { noDead = useWHATWG(n, input); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } assert.ok(noDead); diff --git a/benchmark/url/url-searchparams-iteration.js b/benchmark/url/url-searchparams-iteration.js index 2b13992bdfcfc0..cae2ef5df61956 100644 --- a/benchmark/url/url-searchparams-iteration.js +++ b/benchmark/url/url-searchparams-iteration.js @@ -53,6 +53,6 @@ function main({ method, n }) { iterator(n); break; default: - throw new Error('Unknown method'); + throw new Error(`Unknown method ${method}`); } } diff --git a/benchmark/url/url-searchparams-read.js b/benchmark/url/url-searchparams-read.js index 29235ee81e0e14..0cf66dabbc36dc 100644 --- a/benchmark/url/url-searchparams-read.js +++ b/benchmark/url/url-searchparams-read.js @@ -10,45 +10,14 @@ const bench = common.createBenchmark(main, { const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; -function get(n, param) { - const params = new URLSearchParams(str); - - bench.start(); - for (var i = 0; i < n; i += 1) - params.get(param); - bench.end(n); -} - -function getAll(n, param) { - const params = new URLSearchParams(str); - - bench.start(); - for (var i = 0; i < n; i += 1) - params.getAll(param); - bench.end(n); -} - -function has(n, param) { +function main({ method, param, n }) { const params = new URLSearchParams(str); + const fn = params[method]; + if (!fn) + throw new Error(`Unknown method ${method}`); bench.start(); for (var i = 0; i < n; i += 1) - params.has(param); + fn(param); bench.end(n); } - -function main({ method, param, n }) { - switch (method) { - case 'get': - get(n, param); - break; - case 'getAll': - getAll(n, param); - break; - case 'has': - has(n, param); - break; - default: - throw new Error('Unknown method'); - } -} diff --git a/benchmark/url/url-searchparams-sort.js b/benchmark/url/url-searchparams-sort.js index 524dacb6d52dc4..fe152bf823468f 100644 --- a/benchmark/url/url-searchparams-sort.js +++ b/benchmark/url/url-searchparams-sort.js @@ -37,9 +37,8 @@ function main({ type, n }) { const params = new URLSearchParams(); const array = getParams(input); - var i; bench.start(); - for (i = 0; i < n; i++) { + for (var i = 0; i < n; i++) { params[searchParams] = array.slice(); params.sort(); }