benchmark: adjust configuration for string-decoder bench · nodejs/node@5457c7a

11

'use strict';

22

const common = require('../common.js');

33

const StringDecoder = require('string_decoder').StringDecoder;

4+

const assert = require('node:assert');

4556

const bench = 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 }) {

75767677

const nChunks = chunks.length;

777879+

let avoidDeadCode;

7880

bench.start();

7981

for (let i = 0; i < n; ++i) {

82+

avoidDeadCode = '';

8083

for (let j = 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

}