Browse Source

Fix http benchmark. Wasn't correctly dispatching.

v0.7.4-release
Ryan 16 years ago
parent
commit
65ec2d5db4
  1. 15
      benchmark/static_http_server.js

15
benchmark/static_http_server.js

@ -1,9 +1,11 @@
var concurrency = 30; var concurrency = 30;
var nrequests = 700;
var port = 8000; var port = 8000;
var completed_requests = 0; var n = 700;
var bytes = 1024*5; var bytes = 1024*5;
var requests = 0;
var responses = 0;
var body = ""; var body = "";
for (var i = 0; i < bytes; i++) { for (var i = 0; i < bytes; i++) {
body += "C"; body += "C";
@ -21,10 +23,12 @@ server.listen(port);
function responseListener (res) { function responseListener (res) {
res.addListener("complete", function () { res.addListener("complete", function () {
//puts("response " + completed_requests + " from client " + res.client.id); if (requests < n) {
if (completed_requests++ < nrequests) {
res.client.get("/").finish(responseListener); res.client.get("/").finish(responseListener);
} else { requests++;
}
if (++responses == n) {
server.close(); server.close();
} }
}); });
@ -35,5 +39,6 @@ function onLoad () {
var client = node.http.createClient(port); var client = node.http.createClient(port);
client.id = i; client.id = i;
client.get("/").finish(responseListener); client.get("/").finish(responseListener);
requests++;
} }
} }

Loading…
Cancel
Save