Browse Source

Update benchmark script to new API

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
7c1c89fc29
  1. 3
      benchmark/http_simple.js
  2. 10
      benchmark/static_http_server.js

3
benchmark/http_simple.js

@ -53,6 +53,5 @@ http.createServer(function (req, res) {
} }
); );
res.write(body); res.write(body);
res.close();
res.finish();
}).listen(8000); }).listen(8000);

10
benchmark/static_http_server.js

@ -21,14 +21,16 @@ var server = http.createServer(function (req, res) {
"Content-Length": body.length "Content-Length": body.length
}); });
res.write(body); res.write(body);
res.finish(); res.close();
}) })
server.listen(port); server.listen(port);
function responseListener (res) { function responseListener (res) {
res.addListener("end", function () { res.addListener("end", function () {
if (requests < n) { if (requests < n) {
res.client.request("/").finish(responseListener); var req = res.client.request("/");
req.addListener('response', responseListener);
req.close();
requests++; requests++;
} }
@ -41,6 +43,8 @@ function responseListener (res) {
for (var i = 0; i < concurrency; i++) { for (var i = 0; i < concurrency; i++) {
var client = http.createClient(port); var client = http.createClient(port);
client.id = i; client.id = i;
client.request("/").finish(responseListener); var req = client.request("/");
req.addListener('response', responseListener);
req.close();
requests++; requests++;
} }

Loading…
Cancel
Save