benchmark: improve readability of net benchmarks
PR-URL: https://github.com/nodejs/node/pull/10446 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
d43b14495c
commit
f955c734ba
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user