2017-09-07 19:20:37 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
const PORT = common.PORT;
|
|
|
|
|
2017-09-14 03:48:53 +02:00
|
|
|
const bench = common.createBenchmark(main, {
|
2017-09-07 19:20:37 +02:00
|
|
|
streams: [100, 200, 1000],
|
|
|
|
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
2017-10-16 19:43:40 +02:00
|
|
|
size: [100000],
|
|
|
|
benchmarker: ['h2load']
|
|
|
|
}, { flags: ['--no-warnings', '--expose-http2'] });
|
2017-09-07 19:20:37 +02:00
|
|
|
|
|
|
|
function main(conf) {
|
|
|
|
const m = +conf.streams;
|
|
|
|
const l = +conf.length;
|
2017-09-30 01:00:51 +02:00
|
|
|
const s = +conf.size;
|
2017-09-07 19:20:37 +02:00
|
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('stream', (stream) => {
|
|
|
|
stream.respond();
|
2017-09-30 01:00:51 +02:00
|
|
|
let written = 0;
|
|
|
|
function write() {
|
|
|
|
stream.write('ü'.repeat(s));
|
|
|
|
written += s;
|
|
|
|
if (written < l)
|
|
|
|
setImmediate(write);
|
|
|
|
else
|
|
|
|
stream.end();
|
|
|
|
}
|
|
|
|
write();
|
2017-09-07 19:20:37 +02:00
|
|
|
});
|
|
|
|
server.listen(PORT, () => {
|
|
|
|
bench.http({
|
|
|
|
path: '/',
|
|
|
|
requests: 10000,
|
|
|
|
maxConcurrentStreams: m,
|
|
|
|
}, () => { server.close(); });
|
|
|
|
});
|
|
|
|
}
|