Skip to content

Instantly share code, notes, and snippets.

@berb
Created August 2, 2010 09:08
Show Gist options
  • Save berb/504373 to your computer and use it in GitHub Desktop.
Save berb/504373 to your computer and use it in GitHub Desktop.
var sys = require('sys');
var http = require('http');
for ( var i = 0; i < 24; i++)
{
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/', {
'host' : 'www.google.com'
});
request.end();
request.addListener('response', function(response)
{
response.setEncoding('utf8');
response.addListener('end', function()
{
sys.log("done");
});
});
}
var sys = require('sys');
var http = require('http');
var google = http.createClient(80, 'www.google.com');
for ( var i = 0; i < 24; i++)
{
var request = google.request('GET', '/', {
'host' : 'www.google.com'
});
request.end();
request.addListener('response', function(response)
{
response.setEncoding('utf8');
response.addListener('end', function()
{
sys.log("done");
});
});
}
@berb
Copy link
Author

berb commented Aug 2, 2010

Test results with 24 requests, average of 5 test runs (time to finish all requests):

multiple_clients.js: 196 ms
single_client.js: 2093 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment