From daa9e4bb8e3005af00417f8c4a14c4303771bcc1 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Fri, 25 Jul 2025 17:49:56 -0300 Subject: [PATCH] benchmark: adjust configuration for string-decoder bench MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to https://github.com/nodejs/node/pull/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. PR-URL: https://github.com/nodejs/node/pull/59187 Refs: https://github.com/nodejs/node/pull/59186 Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: Luigi Pinca --- benchmark/string_decoder/string-decoder.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/benchmark/string_decoder/string-decoder.js b/benchmark/string_decoder/string-decoder.js index 8acb9c15bfd..bcb4eace71b 100644 --- a/benchmark/string_decoder/string-decoder.js +++ b/benchmark/string_decoder/string-decoder.js @@ -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], }); @@ -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); }