summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-04-16 06:42:13 -0700
committerRich Trott <rtrott@gmail.com>2019-04-18 10:25:52 -0700
commit3973354951007e352052d4d57989cf6c212d43d3 (patch)
tree71b95d06c6104c9d2e901c116f9cbd24acea6b81 /benchmark
parentf98679f3b29383b504c5f79cf9bc5879efd3cb5d (diff)
downloadandroid-node-v8-3973354951007e352052d4d57989cf6c212d43d3.tar.gz
android-node-v8-3973354951007e352052d4d57989cf6c212d43d3.tar.bz2
android-node-v8-3973354951007e352052d4d57989cf6c212d43d3.zip
benchmark: fix buffer-base64-decode.js
693401d0ddd752e5fa47b882e56e252c42c94c0e 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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/buffers/buffer-base64-decode.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/benchmark/buffers/buffer-base64-decode.js b/benchmark/buffers/buffer-base64-decode.js
index 0ac694fe8c..d05b9ab378 100644
--- a/benchmark/buffers/buffer-base64-decode.js
+++ b/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);