node/benchmark/http2/compat.js
Matteo Collina 9af04ad684 http2: improve compat performance
This bunch of commits help me improve the performance of a http2
server by 8-10%. The benchmarks reports several 1-2% improvements in
various areas.

PR-URL: https://github.com/nodejs/node/pull/25567
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-11 08:50:07 +01:00

36 lines
922 B
JavaScript

'use strict';
const common = require('../common.js');
const path = require('path');
const fs = require('fs');
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
const bench = common.createBenchmark(main, {
requests: [100, 1000, 5000],
streams: [1, 10, 20, 40, 100, 200],
clients: [2],
benchmarker: ['h2load']
}, { flags: ['--no-warnings'] });
function main({ requests, streams, clients }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('request', (req, res) => {
const out = fs.createReadStream(file);
res.setHeader('content-type', 'text/html');
out.pipe(res);
out.on('error', (err) => {
res.destroy();
});
});
server.listen(common.PORT, () => {
bench.http({
path: '/',
requests,
maxConcurrentStreams: streams,
clients,
threads: clients
}, () => { server.close(); });
});
}