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 authored and MylesBorins committed Mar 9, 2017
1 parent 7ecfe49 commit 06c339d
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
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
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
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 06c339d

Please sign in to comment.