summaryrefslogtreecommitdiff
path: root/benchmark/buffers/buffer-base64-decode.js
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/buffers/buffer-base64-decode.js')
-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);