Skip to content

Commit 5457c7a

Browse files
RafaelGSSaduh95
authored andcommitted
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. PR-URL: #59187 Refs: #59186 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 55838e7 commit 5457c7a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎benchmark/string_decoder/string-decoder.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict';
22
constcommon=require('../common.js');
33
constStringDecoder=require('string_decoder').StringDecoder;
4+
constassert=require('node:assert');
45

56
constbench=common.createBenchmark(main,{
67
encoding: ['ascii','utf8','base64-utf8','base64-ascii','utf16le'],
7-
inLen: [32,128,1024,4096],
8-
chunkLen: [16,64,256,1024],
8+
inLen: [32,128,1024],
9+
chunkLen: [16,256,1024],
910
n: [25e5],
1011
});
1112

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

7677
constnChunks=chunks.length;
7778

79+
letavoidDeadCode;
7880
bench.start();
7981
for(leti=0;i<n;++i){
82+
avoidDeadCode='';
8083
for(letj=0;j<nChunks;++j)
81-
sd.write(chunks[j]);
84+
avoidDeadCode+=sd.write(chunks[j]);
8285
}
8386
bench.end(n);
87+
assert.ok(avoidDeadCode);
8488
}

0 commit comments

Comments
(0)