Browse Source

benchmark: improve readability of net benchmarks

PR-URL: https://github.com/nodejs/node/pull/10446
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Brian White 8 years ago
committed by Myles Borins
parent
commit
06c339dcce
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 20
      benchmark/net/net-c2s.js
  2. 20
      benchmark/net/net-pipe.js
  3. 20
      benchmark/net/net-s2c.js

20
benchmark/net/net-c2s.js

@ -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;
}
@ -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();

20
benchmark/net/net-pipe.js

@ -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;
}
@ -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();

20
benchmark/net/net-s2c.js

@ -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;
}
@ -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();

Loading…
Cancel
Save