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'],
|
|
|
|
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) => {});
|
|
|
|
});
|
2018-01-23 12:18:55 +00:00
|
|
|
server.listen(common.PORT, () => {
|
2017-07-17 17:29:42 +00:00
|
|
|
bench.http({
|
|
|
|
path: '/',
|
2017-12-30 02:57:31 +00:00
|
|
|
requests,
|
|
|
|
maxConcurrentStreams: streams,
|
|
|
|
clients,
|
2020-02-12 18:33:33 +00:00
|
|
|
duration,
|
2017-12-30 02:57:31 +00:00
|
|
|
threads: clients
|
2017-07-17 17:29:42 +00:00
|
|
|
}, () => { server.close(); });
|
|
|
|
});
|
|
|
|
}
|