Skip to content

Commit d469a06

Browse files
joyeecheungMylesBorins
authored andcommitted
benchmark: cut down http benchmark run time
PR-URL: #18379 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 4f4bfbe commit d469a06

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

benchmark/_http-benchmarkers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ exports.run = function(options, callback) {
185185
port: exports.PORT,
186186
path: '/',
187187
connections: 100,
188-
duration: 10,
188+
duration: 5,
189189
benchmarker: exports.default_http_benchmarker
190190
}, options);
191191
if (!options.benchmarker) {

benchmark/http/set-header.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
const common = require('../common.js');
3+
const PORT = common.PORT;
4+
5+
const bench = common.createBenchmark(main, {
6+
res: ['normal', 'setHeader', 'setHeaderWH']
7+
});
8+
9+
const type = 'bytes';
10+
const len = 4;
11+
const chunks = 0;
12+
const chunkedEnc = 0;
13+
const c = 50;
14+
15+
// normal: writeHead(status, {...})
16+
// setHeader: statusCode = status, setHeader(...) x2
17+
// setHeaderWH: setHeader(...), writeHead(status, ...)
18+
function main({ res }) {
19+
process.env.PORT = PORT;
20+
var server = require('../fixtures/simple-http-server.js')
21+
.listen(PORT)
22+
.on('listening', function() {
23+
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
24+
25+
bench.http({
26+
path: path,
27+
connections: c
28+
}, function() {
29+
server.close();
30+
});
31+
});
32+
}

benchmark/http/simple.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ const bench = common.createBenchmark(main, {
77
len: [4, 1024, 102400],
88
chunks: [1, 4],
99
c: [50, 500],
10-
chunkedEnc: [1, 0],
11-
res: ['normal', 'setHeader', 'setHeaderWH']
10+
chunkedEnc: [1, 0]
1211
});
1312

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

2019
bench.http({
2120
path: path,

0 commit comments

Comments
 (0)