mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
5c74108891
PR-URL: https://github.com/nodejs/node/pull/46609 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
34 lines
769 B
JavaScript
34 lines
769 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
res: ['normal', 'setHeader', 'setHeaderWH'],
|
|
duration: 5,
|
|
});
|
|
|
|
const type = 'bytes';
|
|
const len = 4;
|
|
const chunks = 0;
|
|
const chunkedEnc = 0;
|
|
const c = 50;
|
|
|
|
// normal: writeHead(status, {...})
|
|
// setHeader: statusCode = status, setHeader(...) x2
|
|
// setHeaderWH: setHeader(...), writeHead(status, ...)
|
|
function main({ res, duration }) {
|
|
const server = require('../fixtures/simple-http-server.js')
|
|
.listen(0)
|
|
.on('listening', () => {
|
|
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
|
|
|
|
bench.http({
|
|
path: path,
|
|
connections: c,
|
|
duration,
|
|
port: server.address().port,
|
|
}, () => {
|
|
server.close();
|
|
});
|
|
});
|
|
}
|