0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/buffers/buffer-zero.js
Ruben Bridgewater 876836b135
benchmark: rename file
PR-URL: https://github.com/nodejs/node/pull/18790
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-03-02 02:09:25 +00:00

20 lines
389 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1024],
type: ['buffer', 'string']
});
const zeroBuffer = Buffer.alloc(0);
const zeroString = '';
function main({ n, type }) {
const data = type === 'buffer' ? zeroBuffer : zeroString;
bench.start();
for (var i = 0; i < n * 1024; i++) Buffer.from(data);
bench.end(n);
}