summaryrefslogtreecommitdiff
path: root/benchmark/http2/write.js
blob: bee1c1b351632f2e4349e7c14efeba50c7fa4405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';

const common = require('../common.js');
const PORT = common.PORT;

const bench = common.createBenchmark(main, {
  streams: [100, 200, 1000],
  length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
}, { flags: ['--no-warnings'] });

function main(conf) {
  const m = +conf.streams;
  const l = +conf.length;
  const http2 = require('http2');
  const server = http2.createServer();
  server.on('stream', (stream) => {
    stream.respond();
    stream.write('ü'.repeat(l));
    stream.end();
  });
  server.listen(PORT, () => {
    bench.http({
      path: '/',
      requests: 10000,
      maxConcurrentStreams: m,
    }, () => { server.close(); });
  });
}