Created
February 29, 2012 08:50
-
-
Save isaacs/1939263 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first start node http_simple.js | |
var http = require('http'); | |
var latency = []; | |
var numRequests = parseInt(process.argv[2], 10) || 100; | |
var maxSockets = parseInt(process.argv[3], 10) || 100; | |
var runs = parseInt(process.argv[4], 10) || 100; | |
var r = 0; | |
var port = parseInt(process.env.PORT, 10) || 8000; | |
var host = 'localhost'; | |
http.globalAgent.maxSockets = maxSockets; | |
run(); | |
function run() { | |
if (r++ === runs) { | |
return finish(); | |
} | |
// make numRequests in parallel | |
// retain the order in which they are *made*. This requires trapping | |
// each one in a closure, since otherwise, we'll of course end | |
// up mostly sorting them in ascending order, since the cb from a | |
// fast request will almost always be called before the cb from a | |
// slow one. | |
var c = numRequests; | |
var lat = []; | |
latency.push(lat); | |
for (var i = 0; i < numRequests; i++) (function (i) { | |
request(function(l) { | |
lat[i] = l; | |
c--; | |
if (c === 0) run(); | |
}); | |
})(i); | |
} | |
function request(cb) { | |
var opts = { host: host, | |
port: port, | |
path: '/bytes/12' }; | |
var start = Date.now(); | |
var req = http.get(opts, function(res) { | |
return cb(Date.now() - start); | |
}); | |
} | |
function finish() { | |
var data = []; | |
latency.forEach(function(run, i) { | |
run.forEach(function(l, j) { | |
data[j] = data[j] || []; | |
data[j][i] = l; | |
}); | |
}); | |
data = data.map(function (l, i) { | |
return l.join('\t') | |
}).join('\n') + '\n'; | |
var fname = 'client_latency_'+numRequests+'_'+maxSockets+'_'+runs+'.tab' | |
require('fs').writeFile(fname, data, function(er) { | |
if (er) throw er; | |
console.log('written: %s', fname); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 7 12 8 11 15 6 6 5 6 | |
12 6 12 8 13 15 10 6 4 6 | |
12 6 12 8 13 15 10 6 4 6 | |
11 6 12 8 12 15 10 7 4 6 | |
11 6 12 8 12 15 10 7 5 7 | |
11 7 11 8 12 15 10 7 4 7 | |
11 7 11 9 12 15 10 7 5 7 | |
11 7 14 9 12 16 10 7 5 7 | |
11 6 12 6 12 15 10 7 5 7 | |
11 6 8 6 10 15 9 7 4 5 | |
10 6 8 6 10 15 9 7 4 5 | |
10 6 8 7 10 15 9 6 5 5 | |
10 7 10 7 10 15 9 6 6 5 | |
10 7 8 7 10 5 8 8 5 5 | |
10 4 7 6 12 5 8 8 6 6 | |
8 5 7 6 12 5 7 8 6 6 | |
10 5 7 5 12 5 7 8 6 6 | |
20 5 7 5 12 10 7 7 6 5 | |
19 7 7 5 12 5 7 4 6 5 | |
19 8 6 6 12 14 7 5 6 6 | |
19 8 6 8 12 14 10 7 6 6 | |
19 8 5 8 12 14 10 7 6 6 | |
19 8 5 8 12 14 10 8 5 6 | |
18 8 6 9 12 13 10 8 7 6 | |
18 8 5 9 12 14 12 8 7 7 | |
18 9 5 9 11 13 11 8 7 7 | |
18 8 5 8 11 13 11 8 7 7 | |
18 12 10 8 11 13 12 8 8 7 | |
12 12 14 9 12 13 12 8 8 8 | |
12 11 14 9 12 12 11 9 8 8 | |
12 9 13 9 11 12 11 9 8 8 | |
12 11 13 9 8 12 11 9 9 8 | |
20 11 13 10 8 12 11 9 12 8 | |
21 11 13 10 8 12 11 9 9 9 | |
21 11 13 10 8 11 11 10 12 9 | |
21 13 13 10 8 12 10 10 13 9 | |
20 13 15 10 8 11 10 11 13 10 | |
20 13 16 10 8 11 10 11 13 10 | |
20 12 15 10 9 11 10 12 13 10 | |
20 11 15 10 9 11 10 12 14 9 | |
20 12 15 11 9 11 11 12 13 12 | |
20 11 15 11 7 11 11 12 14 10 | |
20 12 16 11 10 11 11 11 13 10 | |
19 13 15 10 10 11 11 11 13 10 | |
21 12 15 11 11 11 12 11 12 11 | |
21 12 15 12 10 11 12 11 12 15 | |
21 12 15 12 10 10 12 12 12 11 | |
21 13 14 11 10 10 12 12 12 11 | |
20 13 14 12 10 10 11 3 12 11 | |
20 3 3 4 4 4 3 12 2 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 7 2 3 3 4 2 1 4 2 | |
8 6 2 3 3 2 2 1 2 2 | |
10 5 1 2 2 2 2 1 4 2 | |
10 6 1 2 2 4 2 1 4 1 | |
7 5 1 1 2 1 1 2 2 1 | |
9 6 2 2 3 2 2 2 2 1 | |
9 6 3 2 2 3 2 2 4 1 | |
9 6 3 2 2 3 2 3 4 2 | |
10 6 3 3 2 3 2 3 4 2 | |
10 7 3 3 3 3 2 3 4 2 | |
10 7 3 3 3 3 2 3 3 2 | |
10 7 3 3 3 3 2 3 4 2 | |
10 7 4 3 3 3 2 3 4 2 | |
10 7 4 3 4 3 2 3 4 2 | |
10 7 4 3 3 3 3 3 4 2 | |
11 7 4 3 4 3 3 4 4 2 | |
11 7 4 3 4 4 3 4 4 2 | |
11 5 4 3 4 4 3 4 4 2 | |
11 3 4 3 4 4 3 4 4 3 | |
11 4 4 4 5 4 3 4 4 3 | |
11 4 4 4 5 5 3 4 4 3 | |
11 4 4 4 5 5 3 4 4 3 | |
11 5 4 4 5 5 3 4 4 3 | |
11 5 4 4 5 5 2 4 5 3 | |
12 5 4 4 5 5 3 5 5 3 | |
12 5 5 4 5 5 3 5 5 3 | |
12 5 5 5 5 5 3 5 5 3 | |
12 5 5 4 5 5 3 5 5 3 | |
12 5 5 5 5 6 3 5 5 3 | |
12 5 5 5 6 5 3 5 5 4 | |
11 5 5 5 6 6 3 5 5 5 | |
11 5 5 5 6 6 3 5 5 5 | |
12 6 5 5 6 6 3 5 5 5 | |
12 6 5 5 6 6 3 5 5 5 | |
13 6 4 5 6 6 4 5 6 5 | |
13 6 4 5 6 6 3 5 6 5 | |
13 6 4 5 7 6 4 6 6 5 | |
13 6 4 4 6 6 4 5 6 5 | |
13 6 5 5 6 6 4 5 6 5 | |
13 6 5 5 6 6 4 6 6 5 | |
14 6 5 5 7 6 4 6 6 6 | |
14 6 5 5 8 6 4 6 6 6 | |
13 6 5 5 8 7 4 6 6 6 | |
14 6 5 5 8 7 4 7 6 6 | |
14 6 5 5 8 7 4 7 6 6 | |
14 7 5 5 8 7 4 7 7 6 | |
14 7 5 6 8 7 4 7 6 6 | |
14 7 5 6 8 7 5 7 7 6 | |
14 7 5 6 8 7 4 7 6 6 | |
14 7 5 6 8 7 5 7 7 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var port = parseInt(process.env.PORT, 10) || 8000; | |
var lag = parseInt(process.argv[2], 10) || 100; | |
http.createServer(function(req, res) { | |
res.writeHead(200, { 'content-type': 'text/plain', | |
'content-lengt': '2' }); | |
setTimeout(function() { | |
res.end('ok'); | |
}, lag); | |
}).listen(port, 'localhost'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 112 108 107 110 108 108 106 105 104 | |
110 109 108 104 110 108 105 106 105 104 | |
109 111 108 104 110 108 105 106 105 104 | |
109 110 108 105 108 108 106 106 105 104 | |
109 110 108 105 110 108 106 105 105 104 | |
109 110 109 105 108 107 106 106 104 104 | |
110 110 109 105 108 107 105 105 104 103 | |
110 110 108 105 110 106 105 105 106 103 | |
109 110 106 105 111 109 105 105 104 103 | |
109 109 106 105 110 109 105 105 104 103 | |
108 109 106 105 110 108 106 104 104 103 | |
110 109 106 105 110 107 106 105 105 103 | |
110 109 106 104 111 107 106 105 105 104 | |
110 112 106 104 111 107 105 104 105 104 | |
110 112 106 104 111 107 105 104 105 104 | |
109 112 106 104 109 107 104 104 104 104 | |
113 111 106 104 109 107 104 104 104 105 | |
113 111 106 104 109 107 104 104 104 105 | |
113 111 107 104 109 106 104 104 104 105 | |
113 111 107 105 109 106 105 104 105 105 | |
114 111 105 107 109 106 105 104 106 106 | |
114 111 105 107 109 106 105 104 106 106 | |
114 111 103 107 109 106 105 104 106 104 | |
108 109 103 106 108 109 106 106 106 104 | |
107 109 104 105 108 108 107 105 106 105 | |
107 109 104 105 108 109 106 105 106 104 | |
115 104 104 105 107 109 106 105 105 105 | |
115 109 106 105 107 109 106 106 105 104 | |
115 108 106 106 109 108 106 106 109 107 | |
115 108 106 106 109 108 106 105 108 107 | |
115 108 106 106 107 107 106 105 109 107 | |
115 108 106 106 108 107 106 105 109 106 | |
114 108 109 105 107 107 108 109 109 107 | |
114 107 109 105 107 103 106 107 109 107 | |
114 107 109 103 107 107 106 108 109 107 | |
114 107 109 106 107 107 108 108 109 106 | |
114 107 109 105 110 107 108 107 108 109 | |
114 107 109 107 109 108 108 107 108 108 | |
113 107 109 108 110 107 109 107 108 107 | |
113 111 108 108 110 107 109 107 110 107 | |
114 111 109 108 110 108 109 107 109 102 | |
113 111 109 107 110 108 109 107 109 108 | |
113 109 109 108 110 108 108 107 110 109 | |
113 109 109 107 110 108 108 107 110 108 | |
113 109 108 107 108 108 110 108 109 108 | |
113 110 109 109 108 109 108 108 109 109 | |
113 110 108 109 106 109 108 108 109 109 | |
113 110 102 108 102 109 108 108 109 109 | |
113 110 108 109 106 109 109 109 109 109 | |
112 110 107 109 106 109 103 102 103 109 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 106 104 102 103 102 102 102 102 103 | |
105 106 102 102 101 102 102 102 102 103 | |
105 106 102 102 102 102 102 102 102 103 | |
104 106 103 102 102 102 102 102 102 102 | |
103 106 103 102 102 102 102 102 102 102 | |
204 207 204 203 202 203 203 203 203 202 | |
204 207 204 203 202 203 204 203 203 203 | |
204 207 204 203 202 203 204 204 203 203 | |
204 207 204 203 202 203 204 204 203 203 | |
204 206 204 203 202 203 204 204 203 203 | |
305 307 305 305 303 305 305 305 304 303 | |
307 308 305 304 304 305 305 305 305 303 | |
307 308 305 304 304 305 305 305 305 303 | |
307 308 305 304 304 305 305 304 305 303 | |
307 308 305 304 304 305 305 304 304 303 | |
406 408 406 404 404 405 405 405 405 404 | |
406 408 406 404 405 405 406 405 406 404 | |
406 408 406 404 405 405 406 405 406 404 | |
406 408 406 404 405 405 406 405 405 404 | |
406 405 406 404 405 405 406 405 406 404 | |
507 507 507 505 505 506 506 506 507 505 | |
508 507 507 505 505 507 507 507 507 505 | |
507 508 507 505 505 507 506 506 507 505 | |
508 508 507 505 505 507 506 506 507 505 | |
507 508 507 505 505 507 506 506 507 505 | |
609 609 609 606 606 608 608 608 608 606 | |
609 609 609 606 607 608 608 608 609 606 | |
609 609 608 606 607 608 608 608 609 606 | |
609 609 608 606 607 608 608 608 608 606 | |
609 609 609 606 607 608 608 608 608 606 | |
710 710 709 708 709 709 709 709 709 706 | |
710 710 709 708 709 709 709 709 710 707 | |
710 710 709 708 709 709 709 709 709 707 | |
710 710 709 708 709 709 709 709 709 707 | |
710 710 709 708 709 709 709 709 709 707 | |
811 811 811 809 810 810 811 810 809 807 | |
811 812 811 810 811 810 812 810 810 807 | |
811 812 811 810 810 810 812 810 810 807 | |
811 812 811 809 810 810 812 810 810 807 | |
811 812 811 809 810 810 811 810 810 807 | |
912 912 912 911 912 910 912 910 911 908 | |
913 912 912 911 912 911 912 911 911 908 | |
913 912 912 911 912 911 912 911 911 908 | |
912 912 912 911 912 911 912 910 911 908 | |
913 912 912 911 912 911 912 911 911 908 | |
1014 1014 1013 1012 1013 1012 1013 1012 1012 1009 | |
1014 1014 1013 1012 1013 1012 1013 1012 1012 1009 | |
1014 1014 1013 1012 1014 1012 1013 1012 1012 1009 | |
1014 1014 1013 1012 1013 1012 1013 1012 1012 1009 | |
1014 1014 1013 1012 1013 1012 1013 1012 1012 1009 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In each of these, a column is a single run, and each row is a request's latency.
The numbers in the filename indicate the number of requests per run, the maximum number of sockets, and the number of runs to perform. Note that the values jump around more or less randomly when the maxSockets and numRequests are equal, but stack up in a stepwise fashion when maxSockets is much lower than numRequests.