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 <jasnell@gmail.com>
  • Loading branch information
mscdex committed Jan 5, 2017
1 parent d43b144 commit f955c73
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.emit = function() {};
Writer.prototype.prependListener = 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.emit = function() {};
Writer.prototype.prependListener = 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.emit = function() {};
Writer.prototype.prependListener = 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 f955c73

Please sign in to comment.