Skip to content
Permalink
Browse files

benchmark: fix buffer-base64-decode.js

693401d added stricter range checking
for buffer operations and that apparently seems to have uncovered the
fact that one of our benchmarks was overflowing a buffer. Increase the
buffer size so the benchmark doesn't throw an error anymore.

PR-URL: #27260
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information...
Trott committed Apr 16, 2019
1 parent f98679f commit 3973354951007e352052d4d57989cf6c212d43d3
Showing with 3 additions and 2 deletions.
  1. +3 −2 benchmark/buffers/buffer-base64-decode.js
@@ -9,11 +9,12 @@ const bench = common.createBenchmark(main, {

function main({ n, size }) {
const s = 'abcd'.repeat(size);
const encodedSize = s.length * 3 / 4;
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
s.match(/./); // Flatten string.
assert.strictEqual(s.length % 4, 0);
const b = Buffer.allocUnsafe(s.length / 4 * 3);
b.write(s, 0, s.length, 'base64');
const b = Buffer.allocUnsafe(encodedSize);
b.write(s, 0, encodedSize, 'base64');
bench.start();
for (var i = 0; i < n; i += 1) b.base64Write(s, 0, s.length);
bench.end(n);

0 comments on commit 3973354

Please sign in to comment.
You can’t perform that action at this time.