Skip to content

Commit

Permalink
benchmark: improve readability of net benchmarks
Browse files Browse the repository at this point in the history
PR-URL: #10446
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mscdex authored and MylesBorins committed Mar 7, 2017
1 parent 33a3861 commit deaf3f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions benchmark/net/net-c2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@ Writer.prototype.once = function() {};
Writer.prototype.emit = function() {};


function flow() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
}

function Reader() {
this.flow = this.flow.bind(this);
this.flow = flow.bind(this);
this.readable = true;
}

Expand All @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return dest;
};

Reader.prototype.flow = function() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
};


function server() {
var reader = new Reader();
Expand Down
20 changes: 10 additions & 10 deletions benchmark/net/net-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@ Writer.prototype.once = function() {};
Writer.prototype.emit = function() {};


function flow() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
}

function Reader() {
this.flow = this.flow.bind(this);
this.flow = flow.bind(this);
this.readable = true;
}

Expand All @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return dest;
};

Reader.prototype.flow = function() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
};


function server() {
var reader = new Reader();
Expand Down
20 changes: 10 additions & 10 deletions benchmark/net/net-s2c.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@ Writer.prototype.once = function() {};
Writer.prototype.emit = function() {};


function flow() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
}

function Reader() {
this.flow = this.flow.bind(this);
this.flow = flow.bind(this);
this.readable = true;
}

Expand All @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return dest;
};

Reader.prototype.flow = function() {
var dest = this.dest;
var res = dest.write(chunk, encoding);
if (!res)
dest.once('drain', this.flow);
else
process.nextTick(this.flow);
};


function server() {
var reader = new Reader();
Expand Down

0 comments on commit deaf3f6

Please sign in to comment.