mirror of
https://github.com/nodejs/node.git
synced 2025-05-12 01:46:53 +00:00

In benchmark buffers directory this changes for loops using var to let when it applies for consistency PR-URL: https://github.com/nodejs/node/pull/28867 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Rich Trott <rtrott@gmail.com>
23 lines
519 B
JavaScript
23 lines
519 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
pieces: [4, 16],
|
|
pieceSize: [1, 16, 256],
|
|
withTotalLength: [0, 1],
|
|
n: [8e5]
|
|
});
|
|
|
|
function main({ n, pieces, pieceSize, withTotalLength }) {
|
|
const list = Array.from({ length: pieces })
|
|
.fill(Buffer.allocUnsafe(pieceSize));
|
|
|
|
const totalLength = withTotalLength ? pieces * pieceSize : undefined;
|
|
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
Buffer.concat(list, totalLength);
|
|
}
|
|
bench.end(n);
|
|
}
|