mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
@@ -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: '/',
|
||||
|
||||
Reference in New Issue
Block a user