diff --git a/benchmark/buffers/buffer-base64-decode.js b/benchmark/buffers/buffer-base64-decode.js index 0ac694fe8c4ae7..d05b9ab3787fce 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);