summaryrefslogtreecommitdiff
path: root/benchmark/util/to-usv-string.js
blob: 22d23d3198d1246ae716b287b158116ab0cf0bf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

const common = require('../common');

const BASE = 'string\ud801';

const bench = common.createBenchmark(main, {
  n: [1e5],
  size: [10, 100, 500],
});

function main({ n, size }) {
  const { toUSVString } = require('util');
  const str = BASE.repeat(size);

  bench.start();
  for (let i = 0; i < n; i++) {
    toUSVString(str);
  }
  bench.end(n);
}