• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common.js');
4const path = require('path');
5const fs = require('fs');
6
7const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
8
9const bench = common.createBenchmark(main, {
10  requests: [100, 1000, 5000],
11  streams: [1, 10, 20, 40, 100, 200],
12  clients: [2],
13  benchmarker: ['test-double-http2'],
14  duration: 5,
15}, { flags: ['--no-warnings'] });
16
17function main({ requests, streams, clients, duration }) {
18  fs.open(file, 'r', (err, fd) => {
19    if (err)
20      throw err;
21
22    const http2 = require('http2');
23    const server = http2.createServer();
24    server.on('stream', (stream) => {
25      stream.respondWithFD(fd);
26      stream.on('error', (err) => {});
27    });
28    server.listen(0, () => {
29      bench.http({
30        path: '/',
31        requests,
32        port: server.address().port,
33        maxConcurrentStreams: streams,
34        clients,
35        duration,
36        threads: clients,
37      }, () => server.close());
38    });
39
40  });
41
42}
43