Skip to content

Commit 3ca7a78

Browse files
Trottdanielleadams
authored andcommitted
benchmark: fix http2 benchmarks
Fixes: #36746 PR-URL: #36871 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent cb0b53e commit 3ca7a78

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

benchmark/_test-double-benchmarker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function run() {
4646
}
4747
} else { // HTTP/2
4848
const client = http.connect(url);
49-
client.on('error', (e) => { throw e; });
49+
client.on('error', () => {});
5050
request(client.request(), client);
5151
}
5252
}

benchmark/http2/compat.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ function main({ requests, streams, clients, duration }) {
2424
res.destroy();
2525
});
2626
});
27-
server.listen(common.PORT, () => {
27+
server.listen(0, () => {
2828
bench.http({
2929
path: '/',
30+
port: server.address().port,
3031
requests,
3132
maxConcurrentStreams: streams,
3233
clients,

benchmark/http2/headers.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const PORT = common.PORT;
54

65
const bench = common.createBenchmark(main, {
76
n: [1e3],
@@ -32,8 +31,8 @@ function main({ n, nheaders }) {
3231
stream.respond();
3332
stream.end('Hi!');
3433
});
35-
server.listen(PORT, () => {
36-
const client = http2.connect(`http://localhost:${PORT}/`, {
34+
server.listen(0, () => {
35+
const client = http2.connect(`http://localhost:${server.address().port}/`, {
3736
maxHeaderListPairs: 20000
3837
});
3938

benchmark/http2/respond-with-fd.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ function main({ requests, streams, clients, duration }) {
2525
stream.respondWithFD(fd);
2626
stream.on('error', (err) => {});
2727
});
28-
server.listen(common.PORT, () => {
28+
server.listen(0, () => {
2929
bench.http({
3030
path: '/',
3131
requests,
32+
port: server.address().port,
3233
maxConcurrentStreams: streams,
3334
clients,
3435
duration,

benchmark/http2/simple.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ function main({ requests, streams, clients, duration }) {
2222
out.pipe(stream);
2323
stream.on('error', (err) => {});
2424
});
25-
server.listen(common.PORT, () => {
25+
server.listen(0, () => {
2626
bench.http({
2727
path: '/',
28+
port: server.address().port,
2829
requests,
2930
maxConcurrentStreams: streams,
3031
clients,

benchmark/http2/write.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ function main({ streams, length, size, duration }) {
2626
}
2727
write();
2828
});
29-
server.listen(common.PORT, () => {
29+
server.listen(0, () => {
3030
bench.http({
3131
path: '/',
32+
port: server.address().port,
3233
requests: 10000,
3334
duration,
3435
maxConcurrentStreams: streams,

0 commit comments

Comments
 (0)