Skip to content

Instantly share code, notes, and snippets.

@Twipped
Created March 3, 2012 22:25
Show Gist options
  • Select an option

  • Save Twipped/1968650 to your computer and use it in GitHub Desktop.

Select an option

Save Twipped/1968650 to your computer and use it in GitHub Desktop.
Node.js code for load testing a primal site
#!/usr/bin/env node
var request = require('request');
var rCount = 0,
iterations = 100,
i = iterations,
start = (new Date()).valueOf(),
handler = function (error, response, body) {
rCount--;
console.log('Pop '+rCount);
if (rCount <= 0) {
var stop = (new Date()).valueOf(),
tot = stop - start,
avg = tot / iterations;
console.log('Finished in '+ (tot/1000) + ' Seconds');
console.log('Average '+ (avg/1000) + ' Seconds Per Request');
}
};
while (--i) {
rCount++;
request({
url:'http://www.primal.dev/login',
method:'POST',
form:{
'login[email]':'admin',
'login[password]':'admin'
}
}, handler);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment