• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common.js');
4
5const bench = common.createBenchmark(main, {
6  charsPerLine: [76],
7  linesCount: [8 << 16],
8  n: [32],
9});
10
11function main({ charsPerLine, linesCount, n }) {
12  const bytesCount = charsPerLine * linesCount / 4 * 3;
13
14  const line = `${'abcd'.repeat(charsPerLine / 4)}\n`;
15  const data = line.repeat(linesCount);
16  // eslint-disable-next-line node-core/no-unescaped-regexp-dot
17  data.match(/./);  // Flatten the string
18  const buffer = Buffer.alloc(bytesCount, line, 'base64');
19
20  bench.start();
21  for (let i = 0; i < n; i++) {
22    buffer.base64Write(data, 0, bytesCount);
23  }
24  bench.end(n);
25}
26