Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
benchmark: adjust configuration for string-decoder bench
According to #59186 this
benchmark file takes 6 hours to complete a full benchmark/compare.js
script (60 runs in total) and this regression tests unrealitics to do
between Node.js releases. By using calibrate-n scripts I could find
a better N also ajusting some bench configs. e.g: avoid dead code
elimination by V8.
  • Loading branch information
RafaelGSS committed Jul 23, 2025
commit d5b8dfc8dc29b6ad8d2103f96c3c10d06d65c203
10 changes: 7 additions & 3 deletions benchmark/string_decoder/string-decoder.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';
const common = require('../common.js');
const StringDecoder = require('string_decoder').StringDecoder;
const assert = require('node:assert');

const bench = common.createBenchmark(main, {
encoding: ['ascii', 'utf8', 'base64-utf8', 'base64-ascii', 'utf16le'],
inLen: [32, 128, 1024, 4096],
chunkLen: [16, 64, 256, 1024],
inLen: [32, 128, 1024],
chunkLen: [16, 256, 1024],
n: [25e5],
});

Expand Down Expand Up @@ -75,10 +76,13 @@ function main({ encoding, inLen, chunkLen, n }) {

const nChunks = chunks.length;

let avoidDeadCode;
bench.start();
for (let i = 0; i < n; ++i) {
avoidDeadCode = '';
for (let j = 0; j < nChunks; ++j)
sd.write(chunks[j]);
avoidDeadCode += sd.write(chunks[j]);
}
bench.end(n);
assert.ok(avoidDeadCode);
}
Loading