Skip to content

Commit

Permalink
bench: fix buffers/buffer-base64-encode benchmark
Browse files Browse the repository at this point in the history
The test is supposed to measure the performance of the base64 encoder
so move the Buffer#write() calls out of the benchmark section.

The overhead of the calls isn't terrible (about 1-3%) but having
unrelated activity in a micro-benchmark is never a good idea.

Signed-off-by: Trevor Norris <[email protected]>
  • Loading branch information
bnoordhuis authored and trevnorris committed Jun 4, 2014
1 parent 820aaf5 commit 8ae32a9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions benchmark/buffers/buffer-base64-encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ function main(conf) {
var b = Buffer(N);
var s = '';
for (var i = 0; i < 256; ++i) s += String.fromCharCode(i);

bench.start();
for (var i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii');
bench.start();
for (var i = 0; i < 32; ++i) b.toString('base64');
bench.end(64);
}

0 comments on commit 8ae32a9

Please sign in to comment.