Skip to content

Commit c61db33

Browse files
apapirovskijasnell
authored andcommitted
test: fix long-running buffer benchmarks
PR-URL: #20125 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 2883454 commit c61db33

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

benchmark/buffers/buffer-base64-decode-wrapped.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
const common = require('../common.js');
44

55
const bench = common.createBenchmark(main, {
6+
charsPerLine: [76],
7+
linesCount: [8 << 16],
68
n: [32],
79
});
810

9-
function main({ n }) {
10-
const charsPerLine = 76;
11-
const linesCount = 8 << 16;
11+
function main({ charsPerLine, linesCount, n }) {
1212
const bytesCount = charsPerLine * linesCount / 4 * 3;
1313

1414
const line = `${'abcd'.repeat(charsPerLine / 4)}\n`;

benchmark/buffers/buffer-base64-decode.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ const common = require('../common.js');
44

55
const bench = common.createBenchmark(main, {
66
n: [32],
7+
size: [8 << 20]
78
});
89

9-
function main({ n }) {
10-
const s = 'abcd'.repeat(8 << 20);
10+
function main({ n, size }) {
11+
const s = 'abcd'.repeat(size);
1112
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
1213
s.match(/./); // Flatten string.
1314
assert.strictEqual(s.length % 4, 0);

benchmark/buffers/buffer-indexof.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const bench = common.createBenchmark(main, {
2525
search: searchStrings,
2626
encoding: ['undefined', 'utf8', 'ucs2', 'binary'],
2727
type: ['buffer', 'string'],
28-
iter: [100000]
28+
n: [100000]
2929
});
3030

31-
function main({ iter, search, encoding, type }) {
31+
function main({ n, search, encoding, type }) {
3232
var aliceBuffer = fs.readFileSync(
3333
path.resolve(__dirname, '../fixtures/alice.html')
3434
);
@@ -46,8 +46,8 @@ function main({ iter, search, encoding, type }) {
4646
}
4747

4848
bench.start();
49-
for (var i = 0; i < iter; i++) {
49+
for (var i = 0; i < n; i++) {
5050
aliceBuffer.indexOf(search, 0, encoding);
5151
}
52-
bench.end(iter);
52+
bench.end(n);
5353
}

test/sequential/test-benchmark-buffer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ runBenchmark('buffers',
1010
'args=1',
1111
'buffer=fast',
1212
'byteLength=1',
13+
'charsPerLine=6',
1314
'encoding=utf8',
1415
'endian=BE',
1516
'len=2',
17+
'linesCount=1',
1618
'method=',
1719
'n=1',
1820
'pieces=1',

0 commit comments

Comments
 (0)