Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-09-30 02:00:51 +0300
committerMyles Borins <mylesborins@google.com>2017-10-11 09:05:38 +0300
commit86dfcc609cb50299055193624560a2552af56646 (patch)
treec04de8a15614ad31eefe18361f9c220084bb801c /benchmark
parent68cd233a7bd76ad660038fae5a42bb54178e1831 (diff)
http2: making sending to the socket more efficient
PR-URL: https://github.com/nodejs/node/pull/15693 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http2/write.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/benchmark/http2/write.js b/benchmark/http2/write.js
index 03fe128c6b6..20deff8930b 100644
--- a/benchmark/http2/write.js
+++ b/benchmark/http2/write.js
@@ -6,17 +6,27 @@ const PORT = common.PORT;
const bench = common.createBenchmark(main, {
streams: [100, 200, 1000],
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
+ size: [100000]
}, { flags: ['--expose-http2', '--no-warnings'] });
function main(conf) {
const m = +conf.streams;
const l = +conf.length;
+ const s = +conf.size;
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond();
- stream.write('ü'.repeat(l));
- stream.end();
+ let written = 0;
+ function write() {
+ stream.write('ü'.repeat(s));
+ written += s;
+ if (written < l)
+ setImmediate(write);
+ else
+ stream.end();
+ }
+ write();
});
server.listen(PORT, () => {
bench.http({