2017-07-17 17:29:42 +00:00
|
|
|
'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');
|
|
|
|
|
2017-09-14 01:48:53 +00:00
|
|
|
const bench = common.createBenchmark(main, {
|
2018-10-30 23:17:33 +00:00
|
|
|
requests: [100, 1000, 5000],
|
|
|
|
streams: [1, 10, 20, 40, 100, 200],
|
|
|
|
clients: [2],
|
2020-02-12 18:33:33 +00:00
|
|
|
benchmarker: ['test-double-http2'],
|
2023-02-09 23:15:52 +00:00
|
|
|
duration: 5,
|
2018-05-22 10:10:53 +00:00
|
|
|
}, { flags: ['--no-warnings'] });
|
2017-07-17 17:29:42 +00:00
|
|
|
|
2020-02-12 18:33:33 +00:00
|
|
|
function main({ requests, streams, clients, duration }) {
|
2017-07-17 17:29:42 +00:00
|
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('stream', (stream) => {
|
|
|
|
const out = fs.createReadStream(file);
|
|
|
|
stream.respond();
|
|
|
|
out.pipe(stream);
|
|
|
|
stream.on('error', (err) => {});
|
|
|
|
});
|
2021-01-10 17:08:35 +00:00
|
|
|
server.listen(0, () => {
|
2017-07-17 17:29:42 +00:00
|
|
|
bench.http({
|
|
|
|
path: '/',
|
2021-01-10 17:08:35 +00:00
|
|
|
port: server.address().port,
|
2017-12-30 02:57:31 +00:00
|
|
|
requests,
|
|
|
|
maxConcurrentStreams: streams,
|
|
|
|
clients,
|
2020-02-12 18:33:33 +00:00
|
|
|
duration,
|
2023-02-09 23:15:52 +00:00
|
|
|
threads: clients,
|
2017-07-17 17:29:42 +00:00
|
|
|
}, () => { server.close(); });
|
|
|
|
});
|
|
|
|
}
|