Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var https = require('https');
var tls = require('tls');
var i, now, count = 10000000;
var port = 10443, host = 'localhost', options = {};
var agent = new https.Agent();
// stub function
tls.connect = function() {};
now = Date.now();
for (i = 0; i < count; i++) {
agent.createConnection(port, host, options);
}
console.log('* createConnection(port, host, options) - %d ms', Date.now() - now);
now = Date.now();
for (i = 0; i < count; i++) {
agent.createConnection(port, options);
}
console.log('* createConnection(port, options) - %d ms', Date.now() - now);
now = Date.now();
for (i = 0; i < count; i++) {
agent.createConnection(options);
}
console.log('* createConnection(options) - %d ms', Date.now() - now);
now = Date.now();
for (i = 0; i < count; i++) {
agent.createConnection(port);
}
console.log('* createConnection(port) - %d ms', Date.now() - now);
now = Date.now();
for (i = 0; i < count; i++) {
agent.createConnection(port, host);
}
console.log('* createConnection(port, host) - %d ms', Date.now() - now);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment