Skip to content

Commit d13d900

Browse files
BridgeARevanlucas
authored andcommitted
benchmark: (http2) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 97e8820 commit d13d900

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

benchmark/http2/headers.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ const bench = common.createBenchmark(main, {
99
benchmarker: ['h2load']
1010
}, { flags: ['--no-warnings', '--expose-http2'] });
1111

12-
function main(conf) {
13-
const n = +conf.n;
14-
const nheaders = +conf.nheaders;
12+
function main({ n, nheaders }) {
1513
const http2 = require('http2');
1614
const server = http2.createServer({
1715
maxHeaderListPairs: 20000

benchmark/http2/respond-with-fd.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ const bench = common.createBenchmark(main, {
1414
benchmarker: ['h2load']
1515
}, { flags: ['--no-warnings', '--expose-http2'] });
1616

17-
function main(conf) {
18-
17+
function main({ requests, streams, clients }) {
1918
fs.open(file, 'r', (err, fd) => {
2019
if (err)
2120
throw err;
2221

23-
const n = +conf.requests;
24-
const m = +conf.streams;
25-
const c = +conf.clients;
2622
const http2 = require('http2');
2723
const server = http2.createServer();
2824
server.on('stream', (stream) => {
@@ -32,10 +28,10 @@ function main(conf) {
3228
server.listen(PORT, () => {
3329
bench.http({
3430
path: '/',
35-
requests: n,
36-
maxConcurrentStreams: m,
37-
clients: c,
38-
threads: c
31+
requests,
32+
maxConcurrentStreams: streams,
33+
clients,
34+
threads: clients
3935
}, () => server.close());
4036
});
4137

benchmark/http2/simple.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ const bench = common.createBenchmark(main, {
1515
benchmarker: ['h2load']
1616
}, { flags: ['--no-warnings', '--expose-http2'] });
1717

18-
function main(conf) {
19-
const n = +conf.requests;
20-
const m = +conf.streams;
21-
const c = +conf.clients;
18+
function main({ requests, streams, clients }) {
2219
const http2 = require('http2');
2320
const server = http2.createServer();
2421
server.on('stream', (stream) => {
@@ -30,10 +27,10 @@ function main(conf) {
3027
server.listen(PORT, () => {
3128
bench.http({
3229
path: '/',
33-
requests: n,
34-
maxConcurrentStreams: m,
35-
clients: c,
36-
threads: c
30+
requests,
31+
maxConcurrentStreams: streams,
32+
clients,
33+
threads: clients
3734
}, () => { server.close(); });
3835
});
3936
}

benchmark/http2/write.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ const bench = common.createBenchmark(main, {
1010
benchmarker: ['h2load']
1111
}, { flags: ['--no-warnings', '--expose-http2'] });
1212

13-
function main(conf) {
14-
const m = +conf.streams;
15-
const l = +conf.length;
16-
const s = +conf.size;
13+
function main({ streams, length, size }) {
1714
const http2 = require('http2');
1815
const server = http2.createServer();
1916
server.on('stream', (stream) => {
2017
stream.respond();
2118
let written = 0;
2219
function write() {
23-
stream.write('ü'.repeat(s));
24-
written += s;
25-
if (written < l)
20+
stream.write('ü'.repeat(size));
21+
written += size;
22+
if (written < length)
2623
setImmediate(write);
2724
else
2825
stream.end();
@@ -33,7 +30,7 @@ function main(conf) {
3330
bench.http({
3431
path: '/',
3532
requests: 10000,
36-
maxConcurrentStreams: m,
33+
maxConcurrentStreams: streams,
3734
}, () => { server.close(); });
3835
});
3936
}

0 commit comments

Comments
 (0)