diff options
author | Weijia Wang <381152119@qq.com> | 2019-02-11 13:30:15 +0800 |
---|---|---|
committer | Weijia Wang <381152119@qq.com> | 2019-02-13 21:25:20 +0800 |
commit | da0dc51e396ea4a1f12f259a8149f4177ad674e8 (patch) | |
tree | 2683a1c1f33b8eaa55e5bb528f4cc2e016972690 /benchmark/http | |
parent | 8ecf313324e619d7211adaee76c6b7bb1882e12b (diff) | |
download | android-node-v8-da0dc51e396ea4a1f12f259a8149f4177ad674e8.tar.gz android-node-v8-da0dc51e396ea4a1f12f259a8149f4177ad674e8.tar.bz2 android-node-v8-da0dc51e396ea4a1f12f259a8149f4177ad674e8.zip |
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')
-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 0000000000..a1ab57e238 --- /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(); + }); + }); +} |