0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/buffers/buffer-creation.js

20 lines
411 B
JavaScript

SlowBuffer = require('buffer').SlowBuffer;
var common = require('../common.js');
var bench = common.createBenchmark(main, {
type: ['fast', 'slow'],
len: [10, 1024],
n: [1024]
});
function main(conf) {
var len = +conf.len;
var n = +conf.n;
var clazz = conf.type === 'fast' ? Buffer : SlowBuffer;
bench.start();
for (var i = 0; i < n * 1024; i++) {
b = new clazz(len);
}
bench.end(n);
}