summaryrefslogtreecommitdiff
path: root/benchmark/buffers/buffer-normalize-encoding.js
blob: 1c743c83712ad2aad77b79c9e301b1e4684c4673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';

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

const bench = common.createBenchmark(main, {
  encoding: [
    'ascii',
    'base64',
    'BASE64',
    'binary',
    'hex',
    'HEX',
    'latin1',
    'LATIN1',
    'UCS-2',
    'UCS2',
    'utf-16le',
    'UTF-16LE',
    'utf-8',
    'utf16le',
    'UTF16LE',
    'utf8',
    'UTF8',
  ],
  n: [1e6]
}, {
  flags: ['--expose-internals']
});

function main({ encoding, n }) {
  const { normalizeEncoding } = require('internal/util');

  bench.start();
  for (var i = 0; i < n; i++) {
    normalizeEncoding(encoding);
  }
  bench.end(n);
}