2017-09-07 17:20:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common.js');
|
|
|
|
|
2017-09-14 01:48:53 +00:00
|
|
|
const bench = common.createBenchmark(main, {
|
2017-09-07 17:20:37 +00:00
|
|
|
streams: [100, 200, 1000],
|
|
|
|
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
|
2017-10-16 17:43:40 +00:00
|
|
|
size: [100000],
|
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-09-07 17:20:37 +00:00
|
|
|
|
2020-02-12 18:33:33 +00:00
|
|
|
function main({ streams, length, size, duration }) {
|
2017-09-07 17:20:37 +00:00
|
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('stream', (stream) => {
|
|
|
|
stream.respond();
|
2017-09-29 23:00:51 +00:00
|
|
|
let written = 0;
|
|
|
|
function write() {
|
2017-12-30 02:57:31 +00:00
|
|
|
stream.write('ü'.repeat(size));
|
|
|
|
written += size;
|
|
|
|
if (written < length)
|
2017-09-29 23:00:51 +00:00
|
|
|
setImmediate(write);
|
|
|
|
else
|
|
|
|
stream.end();
|
|
|
|
}
|
|
|
|
write();
|
2017-09-07 17:20:37 +00:00
|
|
|
});
|
2021-01-10 17:08:35 +00:00
|
|
|
server.listen(0, () => {
|
2017-09-07 17:20:37 +00:00
|
|
|
bench.http({
|
|
|
|
path: '/',
|
2021-01-10 17:08:35 +00:00
|
|
|
port: server.address().port,
|
2017-09-07 17:20:37 +00:00
|
|
|
requests: 10000,
|
2020-02-12 18:33:33 +00:00
|
|
|
duration,
|
2017-12-30 02:57:31 +00:00
|
|
|
maxConcurrentStreams: streams,
|
2017-09-07 17:20:37 +00:00
|
|
|
}, () => { server.close(); });
|
|
|
|
});
|
|
|
|
}
|