| 15 | }, { flags: ['--no-warnings'] }); |
| 16 | |
| 17 | function 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 | } |