2017-07-17 19:29:42 +02: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 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2018-10-31 00:17:33 +01:00
|
|
|
requests: [100, 1000, 5000],
|
|
|
|
streams: [1, 10, 20, 40, 100, 200],
|
|
|
|
clients: [2],
|
2017-10-16 19:43:40 +02:00
|
|
|
benchmarker: ['h2load']
|
2018-05-22 12:10:53 +02:00
|
|
|
}, { flags: ['--no-warnings'] });
|
2017-07-17 19:29:42 +02:00
|
|
|
|
2017-12-30 03:57:31 +01:00
|
|
|
function main({ requests, streams, clients }) {
|
2017-07-17 19:29:42 +02:00
|
|
|
fs.open(file, 'r', (err, fd) => {
|
|
|
|
if (err)
|
|
|
|
throw err;
|
|
|
|
|
|
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('stream', (stream) => {
|
|
|
|
stream.respondWithFD(fd);
|
|
|
|
stream.on('error', (err) => {});
|
|
|
|
});
|
2018-01-23 13:18:55 +01:00
|
|
|
server.listen(common.PORT, () => {
|
2017-07-17 19:29:42 +02:00
|
|
|
bench.http({
|
|
|
|
path: '/',
|
2017-12-30 03:57:31 +01:00
|
|
|
requests,
|
|
|
|
maxConcurrentStreams: streams,
|
|
|
|
clients,
|
|
|
|
threads: clients
|
2017-07-17 19:29:42 +02:00
|
|
|
}, () => server.close());
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|