Skip to content

Commit

Permalink
benchmark: cut down http benchmark run time
Browse files Browse the repository at this point in the history
PR-URL: #18379
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
joyeecheung authored and MylesBorins committed Feb 21, 2018
1 parent 4f4bfbe commit d469a06
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion benchmark/_http-benchmarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ exports.run = function(options, callback) {
port: exports.PORT,
path: '/',
connections: 100,
duration: 10,
duration: 5,
benchmarker: exports.default_http_benchmarker
}, options);
if (!options.benchmarker) {
Expand Down
32 changes: 32 additions & 0 deletions benchmark/http/set-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'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();
});
});
}
5 changes: 2 additions & 3 deletions benchmark/http/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ const bench = common.createBenchmark(main, {
len: [4, 1024, 102400],
chunks: [1, 4],
c: [50, 500],
chunkedEnc: [1, 0],
res: ['normal', 'setHeader', 'setHeaderWH']
chunkedEnc: [1, 0]
});

function main({ type, len, chunks, c, chunkedEnc, res }) {
var server = require('../fixtures/simple-http-server.js')
.listen(common.PORT)
.on('listening', function() {
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;

bench.http({
path: path,
Expand Down

0 comments on commit d469a06

Please sign in to comment.