Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Insogna <paolo@cowtech.it>2022-04-13 17:47:59 +0300
committerGitHub <noreply@github.com>2022-04-13 17:47:59 +0300
commit3caa2c1a005652fdb3e896ef940cd5ffe5fdff10 (patch)
treef8e9e9bfe7c95d5633c86e021518f487a9eadb8f /benchmark
parent9d6af7d1fe66afdcb781fb5bad37b4cb4d396f0e (diff)
http: refactor headersTimeout and requestTimeout logic
PR-URL: https://github.com/nodejs/node/pull/41263 Fixes: https://github.com/nodejs/node/issues/33440 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http/chunked.js5
-rw-r--r--benchmark/http/client-request-body.js10
-rw-r--r--benchmark/http/end-vs-write-end.js5
-rw-r--r--benchmark/http/headers.js5
-rw-r--r--benchmark/http/incoming_headers.js5
-rw-r--r--benchmark/http/set-header.js7
-rw-r--r--benchmark/http/simple.js5
-rw-r--r--benchmark/http/upgrade.js2
8 files changed, 24 insertions, 20 deletions
diff --git a/benchmark/http/chunked.js b/benchmark/http/chunked.js
index 9ae7bb7495f..ec86d0a1f65 100644
--- a/benchmark/http/chunked.js
+++ b/benchmark/http/chunked.js
@@ -32,10 +32,11 @@ function main({ len, n, c, duration }) {
send(n);
});
- server.listen(common.PORT, () => {
+ server.listen(0, () => {
bench.http({
connections: c,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/client-request-body.js b/benchmark/http/client-request-body.js
index 6e2323b3f07..3d673d36b7b 100644
--- a/benchmark/http/client-request-body.js
+++ b/benchmark/http/client-request-body.js
@@ -32,7 +32,6 @@ function main({ dur, len, type, method }) {
headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' },
agent: new http.Agent({ maxSockets: 1 }),
host: '127.0.0.1',
- port: common.PORT,
path: '/',
method: 'POST'
};
@@ -40,16 +39,17 @@ function main({ dur, len, type, method }) {
const server = http.createServer((req, res) => {
res.end();
});
- server.listen(options.port, options.host, () => {
+ server.listen(0, options.host, () => {
setTimeout(done, dur * 1000);
bench.start();
- pummel();
+ pummel(server.address().port);
});
- function pummel() {
+ function pummel(port) {
+ options.port = port;
const req = http.request(options, (res) => {
nreqs++;
- pummel(); // Line up next request.
+ pummel(port); // Line up next request.
res.resume();
});
if (method === 'write') {
diff --git a/benchmark/http/end-vs-write-end.js b/benchmark/http/end-vs-write-end.js
index 60174ef3adf..9f128bf8c14 100644
--- a/benchmark/http/end-vs-write-end.js
+++ b/benchmark/http/end-vs-write-end.js
@@ -48,10 +48,11 @@ function main({ len, type, method, c, duration }) {
fn(res);
});
- server.listen(common.PORT, () => {
+ server.listen(0, () => {
bench.http({
connections: c,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/headers.js b/benchmark/http/headers.js
index a3d2b7810be..b405868eb0e 100644
--- a/benchmark/http/headers.js
+++ b/benchmark/http/headers.js
@@ -27,11 +27,12 @@ function main({ len, n, duration }) {
res.writeHead(200, headers);
res.end();
});
- server.listen(common.PORT, () => {
+ server.listen(0, () => {
bench.http({
path: '/',
connections: 10,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/incoming_headers.js b/benchmark/http/incoming_headers.js
index 983bd5632fc..7501d2cb92d 100644
--- a/benchmark/http/incoming_headers.js
+++ b/benchmark/http/incoming_headers.js
@@ -14,7 +14,7 @@ function main({ connections, headers, w, duration }) {
res.end();
});
- server.listen(common.PORT, () => {
+ server.listen(0, () => {
const headers = {
'Content-Type': 'text/plain',
'Accept': 'text/plain',
@@ -34,7 +34,8 @@ function main({ connections, headers, w, duration }) {
path: '/',
connections,
headers,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/set-header.js b/benchmark/http/set-header.js
index 48e0163a6ce..47681ebd1b1 100644
--- a/benchmark/http/set-header.js
+++ b/benchmark/http/set-header.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common.js');
-const PORT = common.PORT;
const bench = common.createBenchmark(main, {
res: ['normal', 'setHeader', 'setHeaderWH'],
@@ -17,16 +16,16 @@ const c = 50;
// setHeader: statusCode = status, setHeader(...) x2
// setHeaderWH: setHeader(...), writeHead(status, ...)
function main({ res, duration }) {
- process.env.PORT = PORT;
const server = require('../fixtures/simple-http-server.js')
- .listen(PORT)
+ .listen(0)
.on('listening', () => {
const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
bench.http({
path: path,
connections: c,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js
index 095b15ca446..31e12ca7c27 100644
--- a/benchmark/http/simple.js
+++ b/benchmark/http/simple.js
@@ -13,14 +13,15 @@ const bench = common.createBenchmark(main, {
function main({ type, len, chunks, c, chunkedEnc, duration }) {
const server = require('../fixtures/simple-http-server.js')
- .listen(common.PORT)
+ .listen(0)
.on('listening', () => {
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
bench.http({
path,
connections: c,
- duration
+ duration,
+ port: server.address().port,
}, () => {
server.close();
});
diff --git a/benchmark/http/upgrade.js b/benchmark/http/upgrade.js
index 8d365fe46df..c4f5cd34228 100644
--- a/benchmark/http/upgrade.js
+++ b/benchmark/http/upgrade.js
@@ -20,7 +20,7 @@ const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' +
function main({ n }) {
const server = require('../fixtures/simple-http-server.js')
- .listen(common.PORT)
+ .listen(0)
.on('listening', () => {
bench.start();
doBench(server.address(), n, () => {