benchmark: adds groups to better separate benchmarks

Fixes: https://github.com/nodejs/node/issues/26425
Co-Authored-By: Yaman Kassir <mestery@protonmail.com>
PR-URL: https://github.com/nodejs/node/pull/54393
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This commit is contained in:
Giovanni Bucci
2024-09-04 05:26:53 +02:00
committed by GitHub
parent b7b96282b2
commit 03fe00e3da
4 changed files with 89 additions and 27 deletions

View File

@@ -4,10 +4,22 @@ const common = require('../common.js');
const http = require('http');
const bench = common.createBenchmark(main, {
n: [10, 600],
len: [1, 100],
duration: 5,
});
fewHeaders: {
n: [10],
len: [1, 5],
duration: 5,
},
mediumHeaders: {
n: [50],
len: [1, 10],
duration: 5,
},
manyHeaders: {
n: [600],
len: [1, 100],
duration: 5,
},
}, { byGroups: true });
function main({ len, n, duration }) {
const headers = {
@@ -15,10 +27,9 @@ function main({ len, n, duration }) {
'Transfer-Encoding': 'chunked',
};
// TODO(BridgeAR): Change this benchmark to use grouped arguments when
// implemented. https://github.com/nodejs/node/issues/26425
const Is = [ ...Array(Math.max(n / len, 1)).keys() ];
const Js = [ ...Array(len).keys() ];
const Is = [...Array(n / len).keys()];
const Js = [...Array(len).keys()];
for (const i of Is) {
headers[`foo${i}`] = Js.map(() => `some header value ${i}`);
}
@@ -27,6 +38,7 @@ function main({ len, n, duration }) {
res.writeHead(200, headers);
res.end();
});
server.listen(0, () => {
bench.http({
path: '/',