Skip to content

Commit

Permalink
fixup! src: improve StreamBase read throughput
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Oct 23, 2018
1 parent 6023661 commit 18069e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions benchmark/net/tcp-raw-c2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions benchmark/net/tcp-raw-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 18069e4

Please sign in to comment.