Script Execution Timing Tutorial for Ajax Server Calls

Published :
Author :
Adam Khoury
Learn to accurately time server script execution in both JavaScript HTML applications and ActionScript 3.0 in Flash applications. Since both languages are so very similar we do not have to change any of the essential code to make the script execution timing possible in both scenarios. We create variables that access the Date() object, then we get total milliseconds since time in the computing world began. Doing this once at the top of your code then once again at the end of your script, you then get how many milliseconds pass while your script runs if you subtract the first variable from the second. <script> function anyFunction(){ // getTime() - returns local total milliseconds for // the date object referenced from Jan 1, 1970 var ms = new Date().getTime(); // Run chunky JavaScript or server Ajax calls to PHP here var execTime = (new Date().getTime() - ms) / 1000; alert(execTime); } anyFunction(); </script>