mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3973354951
693401d0dd
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>
22 lines
593 B
JavaScript
22 lines
593 B
JavaScript
'use strict';
|
|
const assert = require('assert');
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [32],
|
|
size: [8 << 20]
|
|
});
|
|
|
|
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(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);
|
|
}
|