summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/http/end-vs-write-end.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-08-13 12:29:07 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-08-13 12:29:22 +0200
commitda736d8259331a8ef13bf4bbb10bbb8a5c0e5299 (patch)
tree4d849133b1c9a9c7067e96ff7dd8faa1d927e0bb /deps/node/benchmark/http/end-vs-write-end.js
parentda228cf9d71b747f1824e85127039e5afc7effd8 (diff)
downloadakono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.tar.gz
akono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.tar.bz2
akono-da736d8259331a8ef13bf4bbb10bbb8a5c0e5299.zip
remove node/v8 from source tree
Diffstat (limited to 'deps/node/benchmark/http/end-vs-write-end.js')
-rw-r--r--deps/node/benchmark/http/end-vs-write-end.js57
1 files changed, 0 insertions, 57 deletions
diff --git a/deps/node/benchmark/http/end-vs-write-end.js b/deps/node/benchmark/http/end-vs-write-end.js
deleted file mode 100644
index b4ca560b..00000000
--- a/deps/node/benchmark/http/end-vs-write-end.js
+++ /dev/null
@@ -1,57 +0,0 @@
-// When calling .end(buffer) right away, this triggers a "hot path"
-// optimization in http.js, to avoid an extra write call.
-//
-// However, the overhead of copying a large buffer is higher than
-// the overhead of an extra write() call, so the hot path was not
-// always as hot as it could be.
-//
-// Verify that our assumptions are valid.
-'use strict';
-
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: ['asc', 'utf', 'buf'],
- len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
- c: [100],
- method: ['write', 'end']
-});
-
-function main({ len, type, method, c }) {
- const http = require('http');
- var chunk;
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- chunk = 'ΓΌ'.repeat(len / 2);
- break;
- case 'asc':
- chunk = 'a'.repeat(len);
- break;
- }
-
- function write(res) {
- res.write(chunk);
- res.end();
- }
-
- function end(res) {
- res.end(chunk);
- }
-
- const fn = method === 'write' ? write : end;
-
- const server = http.createServer((req, res) => {
- fn(res);
- });
-
- server.listen(common.PORT, () => {
- bench.http({
- connections: c
- }, () => {
- server.close();
- });
- });
-}