Skip to content

Commit

Permalink
benchmark: add benchmark for Buffer.concat
Browse files Browse the repository at this point in the history
PR-URL: #7054
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
addaleax authored and MylesBorins committed Jul 12, 2016
1 parent 7677ace commit 09b4cd1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions benchmark/buffers/buffer-concat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
pieces: [1, 4, 16],
pieceSize: [1, 16, 256],
withTotalLength: [0, 1],
n: [1024]
});

function main(conf) {
const n = +conf.n;
const size = +conf.pieceSize;
const pieces = +conf.pieces;

const list = new Array(pieces);
list.fill(Buffer.allocUnsafe(size));

const totalLength = conf.withTotalLength ? pieces * size : undefined;

bench.start();
for (var i = 0; i < n * 1024; i++) {
Buffer.concat(list, totalLength);
}
bench.end(n);
}

0 comments on commit 09b4cd1

Please sign in to comment.