2016-02-20 02:03:16 +01:00
|
|
|
'use strict';
|
2011-11-05 17:23:33 +01:00
|
|
|
var http = require('http');
|
2010-03-09 04:06:25 +01:00
|
|
|
|
2009-07-13 12:48:59 +02:00
|
|
|
var concurrency = 30;
|
2010-03-23 02:47:04 +01:00
|
|
|
var port = 12346;
|
2011-11-05 17:23:33 +01:00
|
|
|
var n = 700;
|
2016-02-25 07:30:10 +01:00
|
|
|
var bytes = 1024 * 5;
|
2009-07-13 12:48:59 +02:00
|
|
|
|
2009-08-08 21:51:28 +02:00
|
|
|
var requests = 0;
|
|
|
|
var responses = 0;
|
|
|
|
|
2016-02-19 04:01:11 +01:00
|
|
|
var body = 'C'.repeat(bytes);
|
2009-07-13 12:48:59 +02:00
|
|
|
|
2011-11-05 17:23:33 +01:00
|
|
|
var server = http.createServer(function(req, res) {
|
2010-02-25 21:54:48 +01:00
|
|
|
res.writeHead(200, {
|
2011-11-05 17:23:33 +01:00
|
|
|
'Content-Type': 'text/plain',
|
|
|
|
'Content-Length': body.length
|
2009-08-23 12:20:25 +02:00
|
|
|
});
|
2011-11-05 17:23:33 +01:00
|
|
|
res.end(body);
|
2016-02-25 07:30:10 +01:00
|
|
|
});
|
2009-07-13 12:48:59 +02:00
|
|
|
|
2011-11-05 17:23:33 +01:00
|
|
|
server.listen(port, function() {
|
|
|
|
var agent = new http.Agent();
|
|
|
|
agent.maxSockets = concurrency;
|
2009-08-08 21:51:28 +02:00
|
|
|
|
2011-11-05 17:23:33 +01:00
|
|
|
for (var i = 0; i < n; i++) {
|
|
|
|
var req = http.get({
|
|
|
|
port: port,
|
|
|
|
path: '/',
|
|
|
|
agent: agent
|
|
|
|
}, function(res) {
|
2013-01-17 23:54:59 +01:00
|
|
|
res.resume();
|
2011-11-05 17:23:33 +01:00
|
|
|
res.on('end', function() {
|
|
|
|
if (++responses === n) {
|
|
|
|
server.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
req.id = i;
|
|
|
|
requests++;
|
|
|
|
}
|
|
|
|
});
|