• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common.js');
4
5const bench = common.createBenchmark(main, {
6  type: ['ascii', 'mixed', 'emojiseq', 'fullwidth'],
7  n: [10e4]
8}, {
9  flags: ['--expose-internals']
10});
11
12function main({ n, type }) {
13  const { getStringWidth } = require('internal/util/inspect');
14
15  const str = ({
16    ascii: 'foobar'.repeat(100),
17    mixed: 'foo'.repeat(100) + '��' + 'bar'.repeat(100),
18    emojiseq: '��‍��‍��‍����‍��‍��‍����‍��‍��‍����‍��‍��‍��'.repeat(10),
19    fullwidth: '你好'.repeat(150)
20  })[type];
21
22  bench.start();
23  for (let j = 0; j < n; j += 1)
24    getStringWidth(str);
25  bench.end(n);
26}
27