Install apache2-utils
$ sudo apt-get install apache2-utils
Example test:
$ ab -kc 1000 -n 10000 http://www.some-site.cc/tmp/index.php
k
Use HTTP KeepAlive feature c
concurrency Number of multiple requests to make at a time n
requests Number of requests to performOur JavaScript function is far more precise about what kinds of data can be considered empty:
undefined
or null
function isEmpty(data) {
if (typeof(data) == 'number' || typeof(data) == 'boolean') {
return false;
}
if (typeof(data) == 'undefined' || data === null) {
return true;
}
if (typeof(data.length) != 'undefined') {
return data.length === 0;
}
var count = 0, i;
for (i in data) {
if(data.hasOwnProperty(i)) {
count ++;
}
}
return count === 0;
}
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
catch(e){
t = 0;
throw e.toString();
}
}
};
}(wait, times);
setTimeout(interv, wait);
}
The interval function has an internal function called interv which gets invoked automatically via setTimeout, within interv is a closure that checks the the repetition times, invokes the callback and invokes interv again via setTimeout. In case an exception bubbles up from the callback call the interval calling will stop and the exception will be thrown.
This pattern does not guarantee execution on a fixed interval of course, yet it does guarantee that the previous interval has completed before recursing, which I think is much more important.
Usage
interval(function(){
// Code block goes here
}, 1000, 10);
So to execute a piece of code 5 times with an interval or 10 seconds between each you would do something like this: