Created
March 20, 2013 01:42
-
-
Save charliek/5201685 to your computer and use it in GitHub Desktop.
Parameter test
This file contains 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 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