diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-21 08:34:00 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-10-24 09:57:42 +0200 |
commit | 1365f657b51d31044cca54c3152d3940a4bd9dc3 (patch) | |
tree | 4772c2b484555de0a0368b35ebf889ff23d154c2 /benchmark/net | |
parent | bb79e768e5ab150f2075780734005783d53eb3ca (diff) | |
download | android-node-v8-1365f657b51d31044cca54c3152d3940a4bd9dc3.tar.gz android-node-v8-1365f657b51d31044cca54c3152d3940a4bd9dc3.tar.bz2 android-node-v8-1365f657b51d31044cca54c3152d3940a4bd9dc3.zip |
src: improve StreamBase read throughput
Improve performance by providing JS with the raw ingridients
for the read data, i.e. an `ArrayBuffer` + offset + length
fields, instead of creating `Buffer` instances in C++ land.
PR-URL: https://github.com/nodejs/node/pull/23797
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/net')
-rw-r--r-- | benchmark/net/tcp-raw-c2s.js | 8 | ||||
-rw-r--r-- | benchmark/net/tcp-raw-pipe.js | 16 | ||||
-rw-r--r-- | benchmark/net/tcp-raw-s2c.js | 8 |
3 files changed, 16 insertions, 16 deletions
diff --git a/benchmark/net/tcp-raw-c2s.js b/benchmark/net/tcp-raw-c2s.js index 1f10ae7c83..116cf57a23 100644 --- a/benchmark/net/tcp-raw-c2s.js +++ b/benchmark/net/tcp-raw-c2s.js @@ -46,15 +46,15 @@ function main({ dur, len, type }) { process.exit(0); }, dur * 1000); - clientHandle.onread = function(nread, buffer) { + clientHandle.onread = function(buffer) { // we're not expecting to ever get an EOF from the client. // just lots of data forever. - if (nread < 0) - fail(nread, 'read'); + if (!buffer) + fail('read'); // don't slice the buffer. the point of this is to isolate, not // simulate real traffic. - bytes += buffer.length; + bytes += buffer.byteLength; }; clientHandle.readStart(); diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js index 16dc6955c4..7144c237af 100644 --- a/benchmark/net/tcp-raw-pipe.js +++ b/benchmark/net/tcp-raw-pipe.js @@ -43,15 +43,15 @@ function main({ dur, len, type }) { if (err) fail(err, 'connect'); - clientHandle.onread = function(nread, buffer) { + clientHandle.onread = function(buffer) { // we're not expecting to ever get an EOF from the client. // just lots of data forever. - if (nread < 0) - fail(nread, 'read'); + if (!buffer) + fail('read'); const writeReq = new WriteWrap(); writeReq.async = false; - err = clientHandle.writeBuffer(writeReq, buffer); + err = clientHandle.writeBuffer(writeReq, Buffer.from(buffer)); if (err) fail(err, 'write'); @@ -89,11 +89,11 @@ function main({ dur, len, type }) { if (err) fail(err, 'connect'); - clientHandle.onread = function(nread, buffer) { - if (nread < 0) - fail(nread, 'read'); + clientHandle.onread = function(buffer) { + if (!buffer) + fail('read'); - bytes += buffer.length; + bytes += buffer.byteLength; }; connectReq.oncomplete = function(err) { diff --git a/benchmark/net/tcp-raw-s2c.js b/benchmark/net/tcp-raw-s2c.js index 1700d23890..fbb7d2520c 100644 --- a/benchmark/net/tcp-raw-s2c.js +++ b/benchmark/net/tcp-raw-s2c.js @@ -109,15 +109,15 @@ function main({ dur, len, type }) { connectReq.oncomplete = function() { var bytes = 0; - clientHandle.onread = function(nread, buffer) { + clientHandle.onread = function(buffer) { // we're not expecting to ever get an EOF from the client. // just lots of data forever. - if (nread < 0) - fail(nread, 'read'); + if (!buffer) + fail('read'); // don't slice the buffer. the point of this is to isolate, not // simulate real traffic. - bytes += buffer.length; + bytes += buffer.byteLength; }; clientHandle.readStart(); |