xref: /third_party/node/benchmark/url/url-parse.js (revision 1cb0ef41)
1'use strict';
2const common = require('../common.js');
3const url = require('url');
4
5const inputs = {
6  normal: 'http://foo.com/bar',
7  escaped: 'https://foo.bar/{}^`/abcd',
8};
9
10const bench = common.createBenchmark(main, {
11  type: Object.keys(inputs),
12  n: [1e7],
13});
14
15function main({ type, n }) {
16  const input = inputs[type];
17
18  bench.start();
19  for (let i = 0; i < n; i += 1)
20    url.parse(input);
21  bench.end(n);
22}
23