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
Brian White 8 years ago
parent
commit
f955c734ba
No known key found for this signature in database GPG Key ID: 606D7358F94DA209
  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() {}; 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() { function Reader() {
this.flow = this.flow.bind(this); this.flow = flow.bind(this);
this.readable = true; this.readable = true;
} }
@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return 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() { function server() {
var reader = new Reader(); var reader = new Reader();

20
benchmark/net/net-pipe.js

@ -65,8 +65,17 @@ Writer.prototype.emit = function() {};
Writer.prototype.prependListener = 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() { function Reader() {
this.flow = this.flow.bind(this); this.flow = flow.bind(this);
this.readable = true; this.readable = true;
} }
@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return 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() { function server() {
var reader = new Reader(); var reader = new Reader();

20
benchmark/net/net-s2c.js

@ -65,8 +65,17 @@ Writer.prototype.emit = function() {};
Writer.prototype.prependListener = 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() { function Reader() {
this.flow = this.flow.bind(this); this.flow = flow.bind(this);
this.readable = true; this.readable = true;
} }
@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) {
return 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() { function server() {
var reader = new Reader(); var reader = new Reader();

Loading…
Cancel
Save