Skip to content

Commit

Permalink
benchmark: (http2) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent 97e8820 commit d13d900
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions benchmark/http2/respond-with-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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());
});

Expand Down
13 changes: 5 additions & 8 deletions benchmark/http2/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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
Expand Up @@ -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();
Expand All @@ -33,7 +30,7 @@ function main(conf) {
bench.http({
path: '/',
requests: 10000,
maxConcurrentStreams: m,
maxConcurrentStreams: streams,
}, () => { server.close(); });
});
}

0 comments on commit d13d900

Please sign in to comment.