• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10function main({ n, bytes, partial }) {
11  const source = Buffer.allocUnsafe(bytes);
12  const target = Buffer.allocUnsafe(bytes);
13  const sourceStart = (partial === 'true' ? Math.floor(bytes / 2) : 0);
14  bench.start();
15  for (let i = 0; i < n; i++) {
16    source.copy(target, 0, sourceStart);
17  }
18  bench.end(n);
19}
20