mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
Evan Lucas
parent
97e882061d
commit
d13d900eee
@@ -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,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());
|
||||
});
|
||||
|
||||
|
||||
@@ -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(); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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(); });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user