diff options
author | Weijia Wang <381152119@qq.com> | 2019-02-11 08:30:15 +0300 |
---|---|---|
committer | Weijia Wang <381152119@qq.com> | 2019-02-13 16:25:20 +0300 |
commit | da0dc51e396ea4a1f12f259a8149f4177ad674e8 (patch) | |
tree | 2683a1c1f33b8eaa55e5bb528f4cc2e016972690 /benchmark/http/incoming_headers.js | |
parent | 8ecf313324e619d7211adaee76c6b7bb1882e12b (diff) |
http: improve performance for incoming headers
PR-URL: https://github.com/nodejs/node/pull/26041
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'benchmark/http/incoming_headers.js')
-rw-r--r-- | benchmark/http/incoming_headers.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/benchmark/http/incoming_headers.js b/benchmark/http/incoming_headers.js new file mode 100644 index 00000000000..a1ab57e2387 --- /dev/null +++ b/benchmark/http/incoming_headers.js @@ -0,0 +1,35 @@ +'use strict'; +const common = require('../common.js'); +const http = require('http'); + +const bench = common.createBenchmark(main, { + // unicode confuses ab on os x. + c: [50, 500], + headerDuplicates: [0, 5, 20] +}); + +function main({ c, headerDuplicates }) { + const server = http.createServer((req, res) => { + res.end(); + }); + + server.listen(common.PORT, () => { + const headers = { + 'Content-Type': 'text/plain', + 'Accept': 'text/plain', + 'User-Agent': 'nodejs-benchmark', + 'Date': new Date().toString(), + 'Cache-Control': 'no-cache' + }; + for (let i = 0; i < headerDuplicates; i++) { + headers[`foo${i}`] = `some header value ${i}`; + } + bench.http({ + path: '/', + connections: c, + headers + }, () => { + server.close(); + }); + }); +} |