Skip to content

Instantly share code, notes, and snippets.

@emptyhua
Created July 30, 2013 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emptyhua/6111449 to your computer and use it in GitHub Desktop.
Save emptyhua/6111449 to your computer and use it in GitHub Desktop.
压力测试神马的
var Wget = require('./http_request.js').HttpRequest;
var total = 0;
var fail = 0;
setInterval(function() {
console.log(total + 'qps');
console.log(fail + 'failed');
total = 0;
fail = 0;
}, 1000);
function test() {
new Wget({
url:'http://try.maxfs.org/service.php',
cookieStorage:null,
method:'POST',
formData:{
'action':'M_Add',
'params[chat_cid]':'1',
'params[chat_wid]':'1',
'params[chat_uid]':'1',
'params[chat_content]':'游客[time:' + new Date().getTime() + ']'
}
})
.on('error', function(){
total ++;
fail ++;
test();
})
.on('success', function(html) {
if (html.indexOf('"status"') === -1) {
fail ++;
}
total ++;
test();
});
}
for (var i=0;i<500;i++) {
test();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment