diff options
Diffstat (limited to 'benchmark/url/url-resolve.js')
-rw-r--r-- | benchmark/url/url-resolve.js | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/benchmark/url/url-resolve.js b/benchmark/url/url-resolve.js index 8372132e4d..4335511ca6 100644 --- a/benchmark/url/url-resolve.js +++ b/benchmark/url/url-resolve.js @@ -1,36 +1,28 @@ 'use strict'; -var common = require('../common.js'); -var url = require('url'); -var v8 = require('v8'); +const common = require('../common.js'); +const url = require('url'); +const v8 = require('v8'); +const hrefs = require('../fixtures/url-inputs.js').urls; +hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo'; -var hrefs = [ - 'http://example.com/', - 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', - 'http://blog.nodejs.org/', - 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en', - 'javascript:alert("node is awesome");', - 'some.ran/dom/url.thing?oh=yes#whoo' -]; +const paths = { + 'up': '../../../../../etc/passwd', + 'sibling': '../foo/bar?baz=boom', + 'foo/bar': 'foo/bar', + 'withscheme': 'http://nodejs.org', + 'down': './foo/bar?baz' +}; - -var paths = [ - '../../../../../etc/passwd', - '../foo/bar?baz=boom', - 'foo/bar', - 'http://nodejs.org', - './foo/bar?baz' -]; - -var bench = common.createBenchmark(main, { +const bench = common.createBenchmark(main, { href: Object.keys(hrefs), path: Object.keys(paths), n: [1e5] }); function main(conf) { - var n = conf.n | 0; - var href = hrefs[conf.href]; - var path = paths[conf.path]; + const n = conf.n | 0; + const href = hrefs[conf.href]; + const path = paths[conf.path]; // Force-optimize url.resolve() so that the benchmark doesn't get // disrupted by the optimizer kicking in halfway through. |