Skip to content

Commit

Permalink
benchmark: (http2) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: nodejs#18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR authored and MayaLekova committed May 8, 2018
1 parent 77b0074 commit 6ddeb79
Showing 4 changed files with 16 additions and 28 deletions.
4 changes: 1 addition & 3 deletions benchmark/http2/headers.js
Original file line number Diff line number Diff line change
@@ -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
14 changes: 5 additions & 9 deletions benchmark/http2/respond-with-fd.js
Original file line number Diff line number Diff line change
@@ -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());
});

13 changes: 5 additions & 8 deletions benchmark/http2/simple.js
Original file line number Diff line number Diff line change
@@ -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(); });
});
}
13 changes: 5 additions & 8 deletions benchmark/http2/write.js
Original file line number Diff line number Diff line change
@@ -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(); });
});
}

0 comments on commit 6ddeb79

Please sign in to comment.