0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 20:29:23 +01:00
nodejs/benchmark/buffers/buffer-tojson.js

18 lines
296 B
JavaScript
Raw Permalink Normal View History

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1e4],
len: [0, 256, 4 * 1024],
});
function main({ n, len }) {
const buf = Buffer.allocUnsafe(len);
bench.start();
for (let i = 0; i < n; ++i)
buf.toJSON();
bench.end(n);
}