diff --git a/benchmark/http2/headers.js b/benchmark/http2/headers.js index 3c8d0465acb0d0..ad1eb50007a92d 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 791e5f3d1e7da6..6076cf91be9d84 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 e8cb3ddee2dff8..37c78d340181a8 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 91b9c8f0c5c073..7a802ef84fd9ed 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(); }); }); }