summaryrefslogtreecommitdiff
path: root/benchmark/buffers/buffer-zero.js
blob: 81b9731c0a213e472704689314acd9d2054b729d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
  n: [1e6],
  type: ['buffer', 'string']
});

const zeroBuffer = Buffer.alloc(0);
const zeroString = '';

function main({ n, type }) {
  const data = type === 'buffer' ? zeroBuffer : zeroString;

  bench.start();
  for (let i = 0; i < n; i++) Buffer.from(data);
  bench.end(n);
}