• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common.js');
3
4const inputs = {
5  valid: 'adsfadsfadsf',
6  validsurr: '\uda23\ude23\uda1f\udfaa\ud800\udfff\uda23\ude23\uda1f\udfaa' +
7             '\ud800\udfff',
8  someinvalid: 'asasfdfasd\uda23',
9  allinvalid: '\udc45\uda23 \udf00\udc00 \udfaa\uda12 \udc00\udfaa',
10  nonstring: { toString() { return 'asdf'; } },
11};
12const bench = common.createBenchmark(main, {
13  input: Object.keys(inputs),
14  n: [5e7],
15}, {
16  flags: ['--expose-internals'],
17});
18
19function main({ input, n }) {
20  const { toUSVString } = require('internal/url');
21  const str = inputs[input];
22
23  bench.start();
24  for (let i = 0; i < n; i++)
25    toUSVString(str);
26  bench.end(n);
27}
28