| 10 | }); |
| 11 | |
| 12 | function main({ connections, headers, w, duration }) { |
| 13 | const server = http.createServer((req, res) => { |
| 14 | res.end(); |
| 15 | }); |
| 16 | |
| 17 | server.listen(0, () => { |
| 18 | const headers = { |
| 19 | 'Content-Type': 'text/plain', |
| 20 | 'Accept': 'text/plain', |
| 21 | 'User-Agent': 'nodejs-benchmark', |
| 22 | 'Date': new Date().toString(), |
| 23 | 'Cache-Control': 'no-cache', |
| 24 | }; |
| 25 | for (let i = 0; i < headers; i++) { |
| 26 | // Note: |
| 27 | // - autocannon does not send header values with OWS |
| 28 | // - wrk can only send trailing OWS. This is a side-effect of wrk |
| 29 | // processing requests with http-parser before sending them, causing |
| 30 | // leading OWS to be stripped. |
| 31 | headers[`foo${i}`] = `some header value ${i}${' \t'.repeat(w / 2)}`; |
| 32 | } |
| 33 | bench.http({ |
| 34 | path: '/', |
| 35 | connections, |
| 36 | headers, |
| 37 | duration, |
| 38 | port: server.address().port, |
| 39 | }, () => { |
| 40 | server.close(); |
| 41 | }); |
| 42 | }); |
| 43 | } |