1'use strict'; 2const common = require('../common.js'); 3 4const bench = common.createBenchmark(main, { 5 pieces: [4, 16], 6 pieceSize: [1, 16, 256], 7 withTotalLength: [0, 1], 8 n: [8e5] 9}); 10 11function main({ n, pieces, pieceSize, withTotalLength }) { 12 const list = Array.from({ length: pieces }) 13 .fill(Buffer.allocUnsafe(pieceSize)); 14 15 const totalLength = withTotalLength ? pieces * pieceSize : undefined; 16 17 bench.start(); 18 for (let i = 0; i < n; i++) { 19 Buffer.concat(list, totalLength); 20 } 21 bench.end(n); 22} 23