1'use strict'; 2const common = require('../common.js'); 3 4const bench = common.createBenchmark(main, { 5 bytes: [0, 8, 128, 32 * 1024], 6 partial: ['true', 'false'], 7 n: [6e6], 8}, { 9 combinationFilter: (p) => { 10 return (p.partial === 'false' && p.bytes === 0) || 11 (p.partial !== 'false' && p.bytes !== 0); 12 }, 13 test: { partial: 'false', bytes: 0 }, 14}); 15 16function main({ n, bytes, partial }) { 17 const source = Buffer.allocUnsafe(bytes); 18 const target = Buffer.allocUnsafe(bytes); 19 const sourceStart = (partial === 'true' ? Math.floor(bytes / 2) : 0); 20 bench.start(); 21 for (let i = 0; i < n; i++) { 22 source.copy(target, 0, sourceStart); 23 } 24 bench.end(n); 25} 26