Skip to content

Commit 88f4e12

Browse files
RafaelGSSaduh95
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 <rafael.nunu@hotmail.com> PR-URL: #66604 Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 09bce78 commit 88f4e12

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
@@ -9,14 +9,14 @@ const types = [
99
];
1010

1111
const bench = common.createBenchmark(main, {
12-
buffer: ['fast'],
12+
buffer: ['fast', 'slow'],
1313
type: types,
1414
n: [1e6],
15-
byteLength: [1, 2, 3, 4, 5, 6],
15+
byteLength: [1, 2, 4, 6],
1616
});
1717

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

‎benchmark/buffers/buffer-read.js‎

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

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

27-
function main({ n, buf, type }) {
28-
const buff = buf === 'fast' ?
27+
function main({ n, buffer, type }) {
28+
const buff = buffer === 'fast' ?
2929
Buffer.alloc(8) :
3030
require('buffer').SlowBuffer(8);
3131
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
require('buffer').SlowBuffer(8);
7777
const fn = `write${type}`;

0 commit comments

Comments
 (0)