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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
constcommon=require('../common.js');
3+
constPORT=common.PORT;
4+
5+
constbench=common.createBenchmark(main,{
6+
res: ['normal','setHeader','setHeaderWH']
7+
});
8+
9+
consttype='bytes';
10+
constlen=4;
11+
constchunks=0;
12+
constchunkedEnc=0;
13+
constc=50;
14+
15+
// normal: writeHead(status,{...})
16+
// setHeader: statusCode = status, setHeader(...) x2
17+
// setHeaderWH: setHeader(...), writeHead(status, ...)
18+
functionmain({ res }){
19+
process.env.PORT=PORT;
20+
varserver=require('../fixtures/simple-http-server.js')
21+
.listen(PORT)
22+
.on('listening',function(){
23+
constpath=`/${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‎

Lines changed: 2 additions & 3 deletions
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
functionmain({ type, len, chunks, c, chunkedEnc, res }){
1514
varserver=require('../fixtures/simple-http-server.js')
1615
.listen(common.PORT)
1716
.on('listening',function(){
18-
constpath=`/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
17+
constpath=`/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
1918

2019
bench.http({
2120
path: path,

0 commit comments

Comments
(0)