Skip to content

Instantly share code, notes, and snippets.

@tricknotes
Created December 28, 2012 07:48
Show Gist options
  • Save tricknotes/4395584 to your computer and use it in GitHub Desktop.
Save tricknotes/4395584 to your computer and use it in GitHub Desktop.
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