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:
authorRuben Bridgewater <ruben@bridgewater.de>2020-02-12 21:33:33 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2020-03-10 00:35:53 +0300
commit1760c23f756bd2d4b7aab4ce00e21e4a021ea97c (patch)
treeb42ee0461278b041a050b57f7dac3d02642bbfc1 /benchmark/http
parentf64aafa2d532b42cc751571c1c98bb6fb3099ea2 (diff)
benchmark: add `test` and `all` options and improve errors"
This reverts commit 4671d551cf9210434bdadf65ee5654606d24da70 and contains a fix to the issue raised for the revert. PR-URL: https://github.com/nodejs/node/pull/31755 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'benchmark/http')
-rw-r--r--benchmark/http/chunked.js8
-rw-r--r--benchmark/http/cluster.js8
-rw-r--r--benchmark/http/end-vs-write-end.js8
-rw-r--r--benchmark/http/headers.js6
-rw-r--r--benchmark/http/incoming_headers.js16
-rw-r--r--benchmark/http/set-header.js10
-rw-r--r--benchmark/http/simple.js10
7 files changed, 40 insertions, 26 deletions
diff --git a/benchmark/http/chunked.js b/benchmark/http/chunked.js
index 52b4605715c..9ae7bb7495f 100644
--- a/benchmark/http/chunked.js
+++ b/benchmark/http/chunked.js
@@ -13,10 +13,11 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1, 4, 8, 16],
len: [1, 64, 256],
- c: [100]
+ c: [100],
+ duration: 5
});
-function main({ len, n, c }) {
+function main({ len, n, c, duration }) {
const http = require('http');
const chunk = Buffer.alloc(len, '8');
@@ -33,7 +34,8 @@ function main({ len, n, c }) {
server.listen(common.PORT, () => {
bench.http({
- connections: c
+ connections: c,
+ duration
}, () => {
server.close();
});
diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js
index 3bcd061a089..0d97b516ec5 100644
--- a/benchmark/http/cluster.js
+++ b/benchmark/http/cluster.js
@@ -9,14 +9,15 @@ if (cluster.isMaster) {
// Unicode confuses ab on os x.
type: ['bytes', 'buffer'],
len: [4, 1024, 102400],
- c: [50, 500]
+ c: [50, 500],
+ duration: 5,
});
} else {
const port = parseInt(process.env.PORT || PORT);
require('../fixtures/simple-http-server.js').listen(port);
}
-function main({ type, len, c }) {
+function main({ type, len, c, duration }) {
process.env.PORT = PORT;
let workers = 0;
const w1 = cluster.fork();
@@ -32,7 +33,8 @@ function main({ type, len, c }) {
bench.http({
path: path,
- connections: c
+ connections: c,
+ duration
}, () => {
w1.destroy();
w2.destroy();
diff --git a/benchmark/http/end-vs-write-end.js b/benchmark/http/end-vs-write-end.js
index 38e9b89a97a..60174ef3adf 100644
--- a/benchmark/http/end-vs-write-end.js
+++ b/benchmark/http/end-vs-write-end.js
@@ -14,10 +14,11 @@ const bench = common.createBenchmark(main, {
type: ['asc', 'utf', 'buf'],
len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
c: [100],
- method: ['write', 'end']
+ method: ['write', 'end'],
+ duration: 5
});
-function main({ len, type, method, c }) {
+function main({ len, type, method, c, duration }) {
const http = require('http');
let chunk;
switch (type) {
@@ -49,7 +50,8 @@ function main({ len, type, method, c }) {
server.listen(common.PORT, () => {
bench.http({
- connections: c
+ connections: c,
+ duration
}, () => {
server.close();
});
diff --git a/benchmark/http/headers.js b/benchmark/http/headers.js
index f8014a6a085..b83ac17e742 100644
--- a/benchmark/http/headers.js
+++ b/benchmark/http/headers.js
@@ -6,9 +6,10 @@ const http = require('http');
const bench = common.createBenchmark(main, {
n: [10, 1000],
len: [1, 100],
+ duration: 5
});
-function main({ len, n }) {
+function main({ len, n, duration }) {
const headers = {
'Connection': 'keep-alive',
'Transfer-Encoding': 'chunked',
@@ -29,7 +30,8 @@ function main({ len, n }) {
server.listen(common.PORT, () => {
bench.http({
path: '/',
- connections: 10
+ connections: 10,
+ duration
}, () => {
server.close();
});
diff --git a/benchmark/http/incoming_headers.js b/benchmark/http/incoming_headers.js
index 810c92687bd..983bd5632fc 100644
--- a/benchmark/http/incoming_headers.js
+++ b/benchmark/http/incoming_headers.js
@@ -3,12 +3,13 @@ const common = require('../common.js');
const http = require('http');
const bench = common.createBenchmark(main, {
- c: [50], // Concurrent connections
- n: [20], // Number of header lines to append after the common headers
- w: [0, 6], // Amount of trailing whitespace
+ connections: [50], // Concurrent connections
+ headers: [20], // Number of header lines to append after the common headers
+ w: [0, 6], // Amount of trailing whitespace
+ duration: 5
});
-function main({ c, n, w }) {
+function main({ connections, headers, w, duration }) {
const server = http.createServer((req, res) => {
res.end();
});
@@ -21,7 +22,7 @@ function main({ c, n, w }) {
'Date': new Date().toString(),
'Cache-Control': 'no-cache'
};
- for (let i = 0; i < n; i++) {
+ for (let i = 0; i < headers; i++) {
// Note:
// - autocannon does not send header values with OWS
// - wrk can only send trailing OWS. This is a side-effect of wrk
@@ -31,8 +32,9 @@ function main({ c, n, w }) {
}
bench.http({
path: '/',
- connections: c,
- headers
+ connections,
+ headers,
+ duration
}, () => {
server.close();
});
diff --git a/benchmark/http/set-header.js b/benchmark/http/set-header.js
index 1909c0991df..48e0163a6ce 100644
--- a/benchmark/http/set-header.js
+++ b/benchmark/http/set-header.js
@@ -3,7 +3,8 @@ const common = require('../common.js');
const PORT = common.PORT;
const bench = common.createBenchmark(main, {
- res: ['normal', 'setHeader', 'setHeaderWH']
+ res: ['normal', 'setHeader', 'setHeaderWH'],
+ duration: 5
});
const type = 'bytes';
@@ -15,16 +16,17 @@ const c = 50;
// normal: writeHead(status, {...})
// setHeader: statusCode = status, setHeader(...) x2
// setHeaderWH: setHeader(...), writeHead(status, ...)
-function main({ res }) {
+function main({ res, duration }) {
process.env.PORT = PORT;
const server = require('../fixtures/simple-http-server.js')
.listen(PORT)
.on('listening', () => {
- const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
+ const path = `/${type}/${len}/${chunks}/${res}/${chunkedEnc}`;
bench.http({
path: path,
- connections: c
+ connections: c,
+ duration
}, () => {
server.close();
});
diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js
index 95409faa9a8..095b15ca446 100644
--- a/benchmark/http/simple.js
+++ b/benchmark/http/simple.js
@@ -7,18 +7,20 @@ const bench = common.createBenchmark(main, {
len: [4, 1024, 102400],
chunks: [1, 4],
c: [50, 500],
- chunkedEnc: [1, 0]
+ chunkedEnc: [1, 0],
+ duration: 5
});
-function main({ type, len, chunks, c, chunkedEnc, res }) {
+function main({ type, len, chunks, c, chunkedEnc, duration }) {
const server = require('../fixtures/simple-http-server.js')
.listen(common.PORT)
.on('listening', () => {
const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`;
bench.http({
- path: path,
- connections: c
+ path,
+ connections: c,
+ duration
}, () => {
server.close();
});