summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorWeijia Wang <381152119@qq.com>2019-02-11 13:30:15 +0800
committerWeijia Wang <381152119@qq.com>2019-02-13 21:25:20 +0800
commitda0dc51e396ea4a1f12f259a8149f4177ad674e8 (patch)
tree2683a1c1f33b8eaa55e5bb528f4cc2e016972690 /benchmark
parent8ecf313324e619d7211adaee76c6b7bb1882e12b (diff)
downloadandroid-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')
-rw-r--r--benchmark/_http-benchmarkers.js5
-rw-r--r--benchmark/http/incoming_headers.js35
2 files changed, 39 insertions, 1 deletions
diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js
index f456628454..a4d6230039 100644
--- a/benchmark/_http-benchmarkers.js
+++ b/benchmark/_http-benchmarkers.js
@@ -25,8 +25,11 @@ class AutocannonBenchmarker {
'-c', options.connections,
'-j',
'-n',
- `http://127.0.0.1:${options.port}${options.path}`,
];
+ for (const field in options.headers) {
+ args.push('-H', `${field}=${options.headers[field]}`);
+ }
+ args.push(`http://127.0.0.1:${options.port}${options.path}`);
const child = child_process.spawn(this.executable, args);
return child;
}
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();
+ });
+ });
+}