From cca085627b0203e4152e4e50b9ab137f4d357115 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Mon, 27 May 2013 15:58:03 +0800 Subject: [PATCH] Update http / load test, was incorrectly waiting for 'end' event which does not exist on HttpRequest --- examples/http.js | 1 - examples/load.js | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/http.js b/examples/http.js index b1da981..cb45b65 100644 --- a/examples/http.js +++ b/examples/http.js @@ -25,7 +25,6 @@ function processRequest(res, num, startTime) { http.createServer(function (req, res) { if (toobusy()) { res.writeHead(503); - res.end(); return res.end(); } diff --git a/examples/load.js b/examples/load.js index 3eadec6..746ac94 100644 --- a/examples/load.js +++ b/examples/load.js @@ -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, @@ -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();