• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3const url = require('url');
4const hrefs = common.urls;
5hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo';
6
7const paths = {
8  'up': '../../../../../etc/passwd',
9  'sibling': '../foo/bar?baz=boom',
10  'foo/bar': 'foo/bar',
11  'withscheme': 'http://nodejs.org',
12  'down': './foo/bar?baz'
13};
14
15const bench = common.createBenchmark(main, {
16  href: Object.keys(hrefs),
17  path: Object.keys(paths),
18  n: [1e5]
19});
20
21function main({ n, href, path }) {
22  const h = hrefs[href];
23  const p = paths[path];
24
25  bench.start();
26  for (let i = 0; i < n; i += 1)
27    url.resolve(h, p);
28  bench.end(n);
29}
30