Created
July 29, 2014 23:53
-
-
Save christianbundy/4cafdb7a27a4d696b7bb 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
var system = require('system'); | |
var address = 'http://stress-test.meteor.com'; | |
var i = 0; | |
var stopping = false; | |
var newThread = function () { | |
console.log(i++); | |
var t = Date.now(); | |
var page = require('webpage').create(); | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('FAIL to load the address'); | |
} else { | |
t = Date.now() - t; | |
console.log('Load time: ' + t); | |
} | |
}); | |
} | |
// Start a new thread every second. | |
setInterval(function () { | |
if (i < 500) { | |
newThread(); | |
} else if (stopping === false) { | |
stopping = true; | |
// Close after 5 minutes | |
setTimeout(phantom.exit, 5 * 60 * 1000); | |
} | |
}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment