Skip to content

Instantly share code, notes, and snippets.

@jeystaats
Created June 11, 2018 15:40
Show Gist options
  • Save jeystaats/6fd232a4c066bac5fdbe414e29739bc8 to your computer and use it in GitHub Desktop.
Save jeystaats/6fd232a4c066bac5fdbe414e29739bc8 to your computer and use it in GitHub Desktop.
XHR Stresstest
var change = 0;
var simultanius = 0;
var que = 1000; // number of tests
Array(que).join(0).split(0).forEach(function(a,i){
var xhr = new XMLHttpRequest;
xhr.open("GET",'/?' + i); // cacheBust
xhr.onreadystatechange = function() {
if(xhr.readyState == 2){
change++;
simultanius = Math.max(simultanius, change);
}
if(xhr.readyState == 4){
change--;
que--;
if(!que){
console.log(simultanius);
}
}
};
xhr.send();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment