Skip to content

Commit

Permalink
benchmark: fix buffer-base64-decode.js
Browse files Browse the repository at this point in the history
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: nodejs#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 18, 2019
1 parent f98679f commit 3973354
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions benchmark/buffers/buffer-base64-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3973354

Please sign in to comment.