11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common.js'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst bench = common.createBenchmark(main, { 51cb0ef41Sopenharmony_ci bytes: [0, 8, 128, 32 * 1024], 61cb0ef41Sopenharmony_ci partial: ['true', 'false'], 71cb0ef41Sopenharmony_ci n: [6e6], 81cb0ef41Sopenharmony_ci}, { 91cb0ef41Sopenharmony_ci combinationFilter: (p) => { 101cb0ef41Sopenharmony_ci return (p.partial === 'false' && p.bytes === 0) || 111cb0ef41Sopenharmony_ci (p.partial !== 'false' && p.bytes !== 0); 121cb0ef41Sopenharmony_ci }, 131cb0ef41Sopenharmony_ci test: { partial: 'false', bytes: 0 }, 141cb0ef41Sopenharmony_ci}); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cifunction main({ n, bytes, partial }) { 171cb0ef41Sopenharmony_ci const source = Buffer.allocUnsafe(bytes); 181cb0ef41Sopenharmony_ci const target = Buffer.allocUnsafe(bytes); 191cb0ef41Sopenharmony_ci const sourceStart = (partial === 'true' ? Math.floor(bytes / 2) : 0); 201cb0ef41Sopenharmony_ci bench.start(); 211cb0ef41Sopenharmony_ci for (let i = 0; i < n; i++) { 221cb0ef41Sopenharmony_ci source.copy(target, 0, sourceStart); 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci bench.end(n); 251cb0ef41Sopenharmony_ci} 26