2017-03-31 13:21:26 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
|
|
|
|
const bench = common.createBenchmark(main, {
|
2018-04-18 10:15:00 +00:00
|
|
|
charsPerLine: [76],
|
|
|
|
linesCount: [8 << 16],
|
2017-03-31 13:21:26 +00:00
|
|
|
n: [32],
|
|
|
|
});
|
|
|
|
|
2018-04-18 10:15:00 +00:00
|
|
|
function main({ charsPerLine, linesCount, n }) {
|
2017-03-31 13:21:26 +00:00
|
|
|
const bytesCount = charsPerLine * linesCount / 4 * 3;
|
|
|
|
|
2017-04-17 01:01:12 +00:00
|
|
|
const line = `${'abcd'.repeat(charsPerLine / 4)}\n`;
|
2017-03-31 13:21:26 +00:00
|
|
|
const data = line.repeat(linesCount);
|
2018-02-04 19:38:18 +00:00
|
|
|
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
|
2017-03-31 13:21:26 +00:00
|
|
|
data.match(/./); // Flatten the string
|
|
|
|
const buffer = Buffer.alloc(bytesCount, line, 'base64');
|
|
|
|
|
|
|
|
bench.start();
|
2019-07-26 15:54:19 +00:00
|
|
|
for (let i = 0; i < n; i++) {
|
2017-03-31 13:21:26 +00:00
|
|
|
buffer.base64Write(data, 0, bytesCount);
|
|
|
|
}
|
|
|
|
bench.end(n);
|
|
|
|
}
|