summaryrefslogtreecommitdiff
path: root/benchmark/http2
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/http2')
-rw-r--r--benchmark/http2/compat.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/benchmark/http2/compat.js b/benchmark/http2/compat.js
new file mode 100644
index 0000000000..5d06ccf317
--- /dev/null
+++ b/benchmark/http2/compat.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const common = require('../common.js');
+const path = require('path');
+const fs = require('fs');
+const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
+
+const bench = common.createBenchmark(main, {
+ requests: [100, 1000, 5000],
+ streams: [1, 10, 20, 40, 100, 200],
+ clients: [2],
+ benchmarker: ['h2load']
+}, { flags: ['--no-warnings'] });
+
+function main({ requests, streams, clients }) {
+ const http2 = require('http2');
+ const server = http2.createServer();
+ server.on('request', (req, res) => {
+ const out = fs.createReadStream(file);
+ res.setHeader('content-type', 'text/html');
+ out.pipe(res);
+ out.on('error', (err) => {
+ res.destroy();
+ });
+ });
+ server.listen(common.PORT, () => {
+ bench.http({
+ path: '/',
+ requests,
+ maxConcurrentStreams: streams,
+ clients,
+ threads: clients
+ }, () => { server.close(); });
+ });
+}