1'use strict';
2const common = require('../common.js');
3const url = require('url');
4const URL = url.URL;
5const assert = require('assert');
6
7const bench = common.createBenchmark(main, {
8  type: common.urlDataTypes,
9  e: [1],
10});
11
12function main({ type, e }) {
13  const data = common.bakeUrlData(type, e, false, true);
14  const obj = new URL(data[0]);
15  const noDead = {
16    protocol: obj.protocol,
17    auth: `${obj.username}:${obj.password}`,
18    host: obj.host,
19    hostname: obj.hostname,
20    port: obj.port,
21    pathname: obj.pathname,
22    search: obj.search,
23    hash: obj.hash,
24  };
25  const len = data.length;
26  bench.start();
27  for (let i = 0; i < len; i++) {
28    const obj = data[i];
29    noDead.protocol = obj.protocol;
30    noDead.auth = `${obj.username}:${obj.password}`;
31    noDead.host = obj.host;
32    noDead.hostname = obj.hostname;
33    noDead.port = obj.port;
34    noDead.pathname = obj.pathname;
35    noDead.search = obj.search;
36    noDead.hash = obj.hash;
37  }
38  bench.end(len);
39  assert.ok(noDead);
40}
41