Using the script below you can find how much time it took to execute your javascript code.
var startDate = new Date();
// execute your tasks here
var endDate = new Date();
var timeTaken = endDate.getTime() - startDate.getTime();
alert('Time take to execute the script is '+timeTaken+' milliseconds');
You can try this example
// USE OF THIS FUNCTION IS NOT RECOMMENDED, CONSUMES LOT OF SYSTEM RESOURCES
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
var startDate = new Date();
// execute your tasks here
sleep(300); // parameter is milliseconds
var endDate = new Date();
var timeTaken = endDate.getTime() - startDate.getTime();
alert('Time take to execute the script is '+timeTaken+' milliseconds');
sleep function taken from http://www.devcheater.com/#JavaScript sleep by loop. Usage of this sleep function is not recommended, shown only for demo purpose.
Check PHP version here