0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/benchmark/buffers/buffer-tojson.js
Brian White 9fcd842279 buffer: improve toJSON() performance
PR-URL: https://github.com/nodejs/node/pull/10895
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-01-23 13:26:30 +01:00

19 lines
316 B
JavaScript

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