Created
March 3, 2012 22:25
-
-
Save Twipped/1968650 to your computer and use it in GitHub Desktop.
Node.js code for load testing a primal site
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
| #!/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