GeezerVison is showing github.com — benchmark: clean up legacy url benchmarks · ide/node@7ee9504
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/querystring/querystring-parse.js +1-14Lines changed: 1 addition & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | var common = require('../common.js'); | 3 | 3 | var querystring = require('querystring'); | 4 | 4 | var v8 = require('v8'); | 5 | | - | 6 | | -var inputs = { | 7 | | - noencode: 'foo=bar&baz=quux&xyzzy=thud', | 8 | | - multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', | 9 | | - encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud', | 10 | | - encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', | 11 | | - encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', | 12 | | - multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', | 13 | | - multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + | 14 | | - 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', | 15 | | - manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z', | 16 | | - manyblankpairs: '&&&&&&&&&&&&&&&&&&&&&&&&', | 17 | | - altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi' | 18 | | -}; | | 5 | +var inputs = require('../fixtures/url-inputs.js').searchParams; | 19 | 6 |
| 20 | 7 | var bench = common.createBenchmark(main, { | 21 | 8 | type: Object.keys(inputs), | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/url/url-format.js +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,19 +3,20 @@ const common = require('../common.js'); | 3 | 3 | const url = require('url'); | 4 | 4 | const v8 = require('v8'); | 5 | 5 |
| | 6 | +const inputs = { | | 7 | + slashes: {slashes: true, host: 'localhost'}, | | 8 | + file: {protocol: 'file:', pathname: '/foo'}, | | 9 | +}; | | 10 | + | 6 | 11 | const bench = common.createBenchmark(main, { | 7 | | - type: 'one two'.split(' '), | | 12 | + type: Object.keys(inputs), | 8 | 13 | n: [25e6] | 9 | 14 | }); | 10 | 15 |
| 11 | 16 | function main(conf) { | 12 | 17 | const type = conf.type; | 13 | 18 | const n = conf.n | 0; | 14 | 19 |
| 15 | | - const inputs = { | 16 | | - one: {slashes: true, host: 'localhost'}, | 17 | | - two: {protocol: 'file:', pathname: '/foo'}, | 18 | | - }; | 19 | 20 | const input = inputs[type] || ''; | 20 | 21 |
| 21 | 22 | // Force-optimize url.format() so that the benchmark doesn't get | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/url/url-parse.js -37Lines changed: 0 additions & 37 deletions Collapse file Copy file name to clipboardExpand all lines: benchmark/url/url-resolve.js +16-24Lines changed: 16 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -var common = require('../common.js'); | 3 | | -var url = require('url'); | 4 | | -var v8 = require('v8'); | | 2 | +const common = require('../common.js'); | | 3 | +const url = require('url'); | | 4 | +const v8 = require('v8'); | | 5 | +const hrefs = require('../fixtures/url-inputs.js').urls; | | 6 | +hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo'; | 5 | 7 |
| 6 | | -var hrefs = [ | 7 | | - 'http://example.com/', | 8 | | - 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', | 9 | | - 'http://blog.nodejs.org/', | 10 | | - 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en', | 11 | | - 'javascript:alert("node is awesome");', | 12 | | - 'some.ran/dom/url.thing?oh=yes#whoo' | 13 | | -]; | | 8 | +const paths = { | | 9 | + 'up': '../../../../../etc/passwd', | | 10 | + 'sibling': '../foo/bar?baz=boom', | | 11 | + 'foo/bar': 'foo/bar', | | 12 | + 'withscheme': 'http://nodejs.org', | | 13 | + 'down': './foo/bar?baz' | | 14 | +}; | 14 | 15 |
| 15 | | - | 16 | | -var paths = [ | 17 | | - '../../../../../etc/passwd', | 18 | | - '../foo/bar?baz=boom', | 19 | | - 'foo/bar', | 20 | | - 'http://nodejs.org', | 21 | | - './foo/bar?baz' | 22 | | -]; | 23 | | - | 24 | | -var bench = common.createBenchmark(main, { | | 16 | +const bench = common.createBenchmark(main, { | 25 | 17 | href: Object.keys(hrefs), | 26 | 18 | path: Object.keys(paths), | 27 | 19 | n: [1e5] | 28 | 20 | }); | 29 | 21 |
| 30 | 22 | function main(conf) { | 31 | | - var n = conf.n | 0; | 32 | | - var href = hrefs[conf.href]; | 33 | | - var path = paths[conf.path]; | | 23 | + const n = conf.n | 0; | | 24 | + const href = hrefs[conf.href]; | | 25 | + const path = paths[conf.path]; | 34 | 26 |
| 35 | 27 | // Force-optimize url.resolve() so that the benchmark doesn't get | 36 | 28 | // disrupted by the optimizer kicking in halfway through. | |
|