Skip to content

Commit adef722

Browse files
RafaelGSSrichardlau
authored andcommitted
benchmark: fix buffer option in buffer read/write benchmarks
main() read `buf` instead of `buffer`, so every run measured Buffer.allocUnsafeSlow() even when labeled buffer=fast. Also benchmark the slow variant and trim the byteLength matrix. Signed-off-by: RafaelGSS <[email protected]> PR-URL: #66604 Reviewed-By: Ulises Gascón <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent 115731d commit adef722

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎benchmark/buffers/buffer-read-with-byteLength.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ const types = [
1010
];
1111

1212
const bench = common.createBenchmark(main, {
13-
buffer: ['fast'],
13+
buffer: ['fast', 'slow'],
1414
type: types,
1515
n: [1e6],
16-
byteLength: [1, 2, 3, 4, 5, 6],
16+
byteLength: [1, 2, 4, 6],
1717
});
1818

19-
function main({ n, buf, type, byteLength }) {
20-
const buff = buf === 'fast' ?
19+
function main({ n, buffer, type, byteLength }) {
20+
const buff = buffer === 'fast' ?
2121
Buffer.alloc(8) :
2222
Buffer.allocUnsafeSlow(8);
2323
const fn = `read${type}`;

‎benchmark/buffers/buffer-read.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const types = [
2020
];
2121

2222
const bench = common.createBenchmark(main, {
23-
buffer: ['fast'],
23+
buffer: ['fast', 'slow'],
2424
type: types,
2525
n: [1e6],
2626
});
2727

28-
function main({ n, buf, type }) {
29-
const buff = buf === 'fast' ?
28+
function main({ n, buffer, type }) {
29+
const buff = buffer === 'fast' ?
3030
Buffer.alloc(8) :
3131
Buffer.allocUnsafeSlow(8);
3232
const fn = `read${type}`;

‎benchmark/buffers/buffer-write.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const types = [
2727
];
2828

2929
const bench = common.createBenchmark(main, {
30-
buffer: ['fast'],
30+
buffer: ['fast', 'slow'],
3131
type: types,
3232
n: [1e6],
3333
});
@@ -70,8 +70,8 @@ const byteLength = {
7070
writeIntBE: 6,
7171
};
7272

73-
function main({ n, buf, type }) {
74-
const buff = buf === 'fast' ?
73+
function main({ n, buffer, type }) {
74+
const buff = buffer === 'fast' ?
7575
Buffer.alloc(8) :
7676
Buffer.allocUnsafeSlow(8);
7777
const fn = `write${type}`;

0 commit comments

Comments
 (0)