summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-30 03:57:31 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-01-23 01:29:26 +0100
commit50d2554dd183d6fc58d55b2c7c0aa1a086c8253b (patch)
treeb4e8c70c79a7961219ab1641c46558f394e4f48f /benchmark
parentfa3149308eb7af5fae95db99e9c8194e1d4259d1 (diff)
downloadandroid-node-v8-50d2554dd183d6fc58d55b2c7c0aa1a086c8253b.tar.gz
android-node-v8-50d2554dd183d6fc58d55b2c7c0aa1a086c8253b.tar.bz2
android-node-v8-50d2554dd183d6fc58d55b2c7c0aa1a086c8253b.zip
benchmark: (http2) use destructuring
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http2/headers.js4
-rw-r--r--benchmark/http2/respond-with-fd.js14
-rw-r--r--benchmark/http2/simple.js13
-rw-r--r--benchmark/http2/write.js13
4 files changed, 16 insertions, 28 deletions
diff --git a/benchmark/http2/headers.js b/benchmark/http2/headers.js
index 3c8d0465ac..ad1eb50007 100644
--- a/benchmark/http2/headers.js
+++ b/benchmark/http2/headers.js
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
benchmarker: ['h2load']
}, { flags: ['--no-warnings', '--expose-http2'] });
-function main(conf) {
- const n = +conf.n;
- const nheaders = +conf.nheaders;
+function main({ n, nheaders }) {
const http2 = require('http2');
const server = http2.createServer({
maxHeaderListPairs: 20000
diff --git a/benchmark/http2/respond-with-fd.js b/benchmark/http2/respond-with-fd.js
index 791e5f3d1e..6076cf91be 100644
--- a/benchmark/http2/respond-with-fd.js
+++ b/benchmark/http2/respond-with-fd.js
@@ -14,15 +14,11 @@ const bench = common.createBenchmark(main, {
benchmarker: ['h2load']
}, { flags: ['--no-warnings', '--expose-http2'] });
-function main(conf) {
-
+function main({ requests, streams, clients }) {
fs.open(file, 'r', (err, fd) => {
if (err)
throw err;
- const n = +conf.requests;
- const m = +conf.streams;
- const c = +conf.clients;
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
@@ -32,10 +28,10 @@ function main(conf) {
server.listen(PORT, () => {
bench.http({
path: '/',
- requests: n,
- maxConcurrentStreams: m,
- clients: c,
- threads: c
+ requests,
+ maxConcurrentStreams: streams,
+ clients,
+ threads: clients
}, () => server.close());
});
diff --git a/benchmark/http2/simple.js b/benchmark/http2/simple.js
index e8cb3ddee2..37c78d3401 100644
--- a/benchmark/http2/simple.js
+++ b/benchmark/http2/simple.js
@@ -15,10 +15,7 @@ const bench = common.createBenchmark(main, {
benchmarker: ['h2load']
}, { flags: ['--no-warnings', '--expose-http2'] });
-function main(conf) {
- const n = +conf.requests;
- const m = +conf.streams;
- const c = +conf.clients;
+function main({ requests, streams, clients }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
@@ -30,10 +27,10 @@ function main(conf) {
server.listen(PORT, () => {
bench.http({
path: '/',
- requests: n,
- maxConcurrentStreams: m,
- clients: c,
- threads: c
+ requests,
+ maxConcurrentStreams: streams,
+ clients,
+ threads: clients
}, () => { server.close(); });
});
}
diff --git a/benchmark/http2/write.js b/benchmark/http2/write.js
index 91b9c8f0c5..7a802ef84f 100644
--- a/benchmark/http2/write.js
+++ b/benchmark/http2/write.js
@@ -10,19 +10,16 @@ const bench = common.createBenchmark(main, {
benchmarker: ['h2load']
}, { flags: ['--no-warnings', '--expose-http2'] });
-function main(conf) {
- const m = +conf.streams;
- const l = +conf.length;
- const s = +conf.size;
+function main({ streams, length, size }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond();
let written = 0;
function write() {
- stream.write('ü'.repeat(s));
- written += s;
- if (written < l)
+ stream.write('ü'.repeat(size));
+ written += size;
+ if (written < length)
setImmediate(write);
else
stream.end();
@@ -33,7 +30,7 @@ function main(conf) {
bench.http({
path: '/',
requests: 10000,
- maxConcurrentStreams: m,
+ maxConcurrentStreams: streams,
}, () => { server.close(); });
});
}