PR-URL: https://github.com/nodejs/node/pull/18379 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
32 lines
755 B
JavaScript
32 lines
755 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const PORT = common.PORT;
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
res: ['normal', 'setHeader', 'setHeaderWH']
|
|
});
|
|
|
|
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 }) {
|
|
process.env.PORT = PORT;
|
|
var server = require('../fixtures/simple-http-server.js')
|
|
.listen(PORT)
|
|
.on('listening', function() {
|
|
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
|
|
|
|
bench.http({
|
|
path: path,
|
|
connections: c
|
|
}, function() {
|
|
server.close();
|
|
});
|
|
});
|
|
}
|