Skip to content

Commit

Permalink
Update http / load test, was incorrectly waiting for 'end' event whic…
Browse files Browse the repository at this point in the history
…h does not exist on HttpRequest
  • Loading branch information
Samuel Reed committed May 29, 2013
1 parent 5224d8b commit cca0856
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion examples/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function processRequest(res, num, startTime) {
http.createServer(function (req, res) {
if (toobusy()) {
res.writeHead(503);
res.end();
return res.end();
}

Expand Down
22 changes: 10 additions & 12 deletions examples/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ setInterval(function() {
if (endOrError) console.log("end AND error");
endOrError = true;
}
http.request({
var req = http.get({
host: '127.0.0.1',
port: 3000,
agent: false,
Expand All @@ -38,23 +38,21 @@ setInterval(function() {
"connection": "close"
}
}, function(res) {
res.on('end', function() {
if (res.statusCode === 503) {
fiveOhThree++;
} else {
twoHundred++;
}
avg = ((new Date() - start) + avg * started) / (started + 1);
running--;
cEndOrError();
});
if (res.statusCode === 503) {
fiveOhThree++;
} else {
twoHundred++;
}
avg = ((new Date() - start) + avg * started) / (started + 1);
running--;
cEndOrError();
}).on('error', function(e) {
process.stderr.write(e.toString() + " - " + (new Date() - start) + "ms\n");
avg = ((new Date() - start) + avg * started) / (started + 1);
running--;
yucky++;
cEndOrError();
}).end();
});
}

for (var i = 0; i < curRPS ; i++) startOne();
Expand Down

0 comments on commit cca0856

Please sign in to comment.