Skip to content

Instantly share code, notes, and snippets.

@charliek
Created March 20, 2013 01:42
Show Gist options
  • Save charliek/5201685 to your computer and use it in GitHub Desktop.
Save charliek/5201685 to your computer and use it in GitHub Desktop.
Parameter test
var paramPrefix = 'charliek';
var iterations = 1000;
function foundAll(postValues, rtnStr) {
var notFound = ''
$.each(postValues, function( key, value ) {
var expected = key + ':' + value;
if(rtnStr.indexOf(expected) == -1) {
notFound += '\t' + expected + '\n'
}
});
return notFound
}
function postData(postValues, iteration) {
$.post(url, postValues, function(rtnStr, textStatus) {
var notFound = foundAll(postValues, rtnStr);
if(notFound === '') {
console.log('found');
} else {
console.log("didn't find all vaues for iteration " + iteration);
console.log(notFound);
}
});
}
for (var i = 0; i < iterations; i++) {
var url = '/bloomhealth/echoParam/index';
var data = {};
var numVariables = Math.floor(i / 5) + 1;
for(var n = 0; n < numVariables; n++) {
data[paramPrefix + n] = i + '-' + n;
}
postData(data, i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment