11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci pieces: [4, 16], 61cb0ef41Sopenharmony_ci pieceSize: [1, 16, 256], 71cb0ef41Sopenharmony_ci withTotalLength: [0, 1], 81cb0ef41Sopenharmony_ci n: [8e5], 91cb0ef41Sopenharmony_ci}); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cifunction main({ n, pieces, pieceSize, withTotalLength }) { 121cb0ef41Sopenharmony_ci const list = Array.from({ length: pieces }) 131cb0ef41Sopenharmony_ci .fill(Buffer.allocUnsafe(pieceSize)); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const totalLength = withTotalLength ? pieces * pieceSize : undefined; 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci bench.start(); 181cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 191cb0ef41Sopenharmony_ci Buffer.concat(list, totalLength); 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci bench.end(n); 221cb0ef41Sopenharmony_ci} 23