summaryrefslogtreecommitdiff
path: root/benchmark/url/legacy-url-parse.js
blob: ac893ebf8ad12e8ad660d6564bc0064628834122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const common = require('../common.js');
const url = require('url');
const assert = require('assert');

const bench = common.createBenchmark(main, {
  type: common.urlDataTypes,
  e: [1],
});

function main({ e, type }) {
  const data = common.bakeUrlData(type, e, false, false);
  let result = url.parse(data[0]);  // Avoid dead code elimination

  bench.start();
  for (let i = 0; i < data.length; ++i) {
    result = url.parse(data[i]);
  }
  bench.end(data.length);

  assert.ok(result);
}