Skip to content

Instantly share code, notes, and snippets.

@tlivings
Created October 20, 2015 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlivings/1bfe110899b68fff9d22 to your computer and use it in GitHub Desktop.
Save tlivings/1bfe110899b68fff9d22 to your computer and use it in GitHub Desktop.
Testing connect time
wrk -c 30 -d 30s -t 30 http://127.0.0.1:8888
'use strict';
var Http = require('http');
var server = Http.createServer(function (req, res) {
res.writeHead(200);
res.end('OK');
});
server.listen(8887);
'use strict';
var Http = require('http');
var server = Http.createServer(function (req, res) {
var request = Http.request({
method: 'GET',
hostname: '127.0.0.1',
port: 8887
}, function (response) {
res.writeHead(200);
res.end();
});
request.once('socket', function (socket) {
var start = Date.now();
socket.once('connect', function () {
var time = Date.now() - start;
if (time > 100) {
console.log('connect in %d/ms.', time);
}
});
});
request.end();
});
server.listen(8888);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment