| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ function useWHATWG(n, input) { | |||
| 74 | 74 | function main({ type, n, method }) { | |
| 75 | 75 | const input = inputs[type]; | |
| 76 | 76 | if (!input) { | |
| 77 | - throw new Error('Unknown input type'); | ||
| 77 | + throw new Error(`Unknown input type "${type}"`); | ||
| 78 | 78 | } | |
| 79 | 79 | ||
| 80 | 80 | var noDead; // Avoid dead code elimination. | |
@@ -86,7 +86,7 @@ function main({ type, n, method }) { | |||
| 86 | 86 | noDead = useWHATWG(n, input); | |
| 87 | 87 | break; | |
| 88 | 88 | default: | |
| 89 | - throw new Error('Unknown method'); | ||
| 89 | + throw new Error(`Unknown method "${method}"`); | ||
| 90 | 90 | } | |
| 91 | 91 | ||
| 92 | 92 | assert.ok(noDead); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,7 @@ function useWHATWG(n, input) { | |||
| 34 | 34 | function main({ type, n, method }) { | |
| 35 | 35 | const input = inputs[type]; | |
| 36 | 36 | if (!input) { | |
| 37 | - throw new Error('Unknown input type'); | ||
| 37 | + throw new Error(`Unknown input type "${type}"`); | ||
| 38 | 38 | } | |
| 39 | 39 | ||
| 40 | 40 | var noDead; // Avoid dead code elimination. | |
@@ -46,7 +46,7 @@ function main({ type, n, method }) { | |||
| 46 | 46 | noDead = useWHATWG(n, input); | |
| 47 | 47 | break; | |
| 48 | 48 | default: | |
| 49 | - throw new Error('Unknown method'); | ||
| 49 | + throw new Error(`Unknown method ${method}`); | ||
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | 52 | assert.ok(noDead); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ function useWHATWG(n, input) { | |||
| 31 | 31 | function main({ type, n, method }) { | |
| 32 | 32 | const input = inputs[type]; | |
| 33 | 33 | if (!input) { | |
| 34 | - throw new Error('Unknown input type'); | ||
| 34 | + throw new Error(`Unknown input type "${type}"`); | ||
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | 37 | switch (method) { | |
@@ -42,6 +42,6 @@ function main({ type, n, method }) { | |||
| 42 | 42 | useWHATWG(n, input); | |
| 43 | 43 | break; | |
| 44 | 44 | default: | |
| 45 | - throw new Error('Unknown method'); | ||
| 45 | + throw new Error(`Unknown method ${method}`); | ||
| 46 | 46 | } | |
| 47 | 47 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ function useWHATWG(n, input, prop) { | |||
| 33 | 33 | function main({ type, n, method }) { | |
| 34 | 34 | const input = inputs[type]; | |
| 35 | 35 | if (!input) { | |
| 36 | - throw new Error('Unknown input type'); | ||
| 36 | + throw new Error(`Unknown input type "${type}"`); | ||
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | switch (method) { | |
@@ -44,6 +44,6 @@ function main({ type, n, method }) { | |||
| 44 | 44 | useWHATWG(n, input); | |
| 45 | 45 | break; | |
| 46 | 46 | default: | |
| 47 | - throw new Error('Unknown method'); | ||
| 47 | + throw new Error(`Unknown method ${method}`); | ||
| 48 | 48 | } | |
| 49 | 49 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ function useWHATWG(n, input, prop) { | |||
| 36 | 36 | function main({ type, n, method }) { | |
| 37 | 37 | const input = inputs[type]; | |
| 38 | 38 | if (!input) { | |
| 39 | - throw new Error('Unknown input type'); | ||
| 39 | + throw new Error(`Unknown input type "${type}"`); | ||
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | var noDead; // Avoid dead code elimination. | |
@@ -48,7 +48,7 @@ function main({ type, n, method }) { | |||
| 48 | 48 | noDead = useWHATWG(n, input); | |
| 49 | 49 | break; | |
| 50 | 50 | default: | |
| 51 | - throw new Error('Unknown method'); | ||
| 51 | + throw new Error(`Unknown method ${method}`); | ||
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | 54 | assert.ok(noDead); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,6 +53,6 @@ function main({ method, n }) { | |||
| 53 | 53 | iterator(n); | |
| 54 | 54 | break; | |
| 55 | 55 | default: | |
| 56 | - throw new Error('Unknown method'); | ||
| 56 | + throw new Error(`Unknown method ${method}`); | ||
| 57 | 57 | } | |
| 58 | 58 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,45 +10,14 @@ const bench = common.createBenchmark(main, { | |||
| 10 | 10 | ||
| 11 | 11 | const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; | |
| 12 | 12 | ||
| 13 | - function get(n, param) { | ||
| 14 | - const params = new URLSearchParams(str); | ||
| 15 | - | ||
| 16 | - bench.start(); | ||
| 17 | - for (var i = 0; i < n; i += 1) | ||
| 18 | - params.get(param); | ||
| 19 | - bench.end(n); | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - function getAll(n, param) { | ||
| 23 | - const params = new URLSearchParams(str); | ||
| 24 | - | ||
| 25 | - bench.start(); | ||
| 26 | - for (var i = 0; i < n; i += 1) | ||
| 27 | - params.getAll(param); | ||
| 28 | - bench.end(n); | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - function has(n, param) { | ||
| 13 | + function main({ method, param, n }) { | ||
| 32 | 14 | const params = new URLSearchParams(str); | |
| 15 | + const fn = params[method]; | ||
| 16 | + if (!fn) | ||
| 17 | + throw new Error(`Unknown method ${method}`); | ||
| 33 | 18 | ||
| 34 | 19 | bench.start(); | |
| 35 | 20 | for (var i = 0; i < n; i += 1) | |
| 36 | - params.has(param); | ||
| 21 | + fn(param); | ||
| 37 | 22 | bench.end(n); | |
| 38 | 23 | } | |
| 39 | - | ||
| 40 | - function main({ method, param, n }) { | ||
| 41 | - switch (method) { | ||
| 42 | - case 'get': | ||
| 43 | - get(n, param); | ||
| 44 | - break; | ||
| 45 | - case 'getAll': | ||
| 46 | - getAll(n, param); | ||
| 47 | - break; | ||
| 48 | - case 'has': | ||
| 49 | - has(n, param); | ||
| 50 | - break; | ||
| 51 | - default: | ||
| 52 | - throw new Error('Unknown method'); | ||
| 53 | - } | ||
| 54 | - } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,9 +37,8 @@ function main({ type, n }) { | |||
| 37 | 37 | const params = new URLSearchParams(); | |
| 38 | 38 | const array = getParams(input); | |
| 39 | 39 | ||
| 40 | - var i; | ||
| 41 | 40 | bench.start(); | |
| 42 | - for (i = 0; i < n; i++) { | ||
| 41 | + for (var i = 0; i < n; i++) { | ||
| 43 | 42 | params[searchParams] = array.slice(); | |
| 44 | 43 | params.sort(); | |
| 45 | 44 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments