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>
This commit is contained in:
Ruben Bridgewater authored and Evan Lucas committed 2018-01-30 14:25:25 -06:00
1 parent 97e882061d
commit d13d900eee
4 files changed
+16 -28

No files matched your search

+1 -3
View File
@@ -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
+5 -9
View File
@@ -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());
});
+5 -8
View File
@@ -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(); });
});
}
+5 -8
View File
@@ -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(); });
});
}