Here is an object literal version of a script to calculate JavaScript execution time. It may be useful in development to compare the performance of different scripts. The advantage of the object literal version is that it is compact and should not interfere with existing script function names.
var timeDiff = {
setStartTime:function (){
d = new Date();
time = d.getTime();
},
getDiff:function (){
d = new Date();
return (d.getTime()-time);
}
}
Use it as follows: call timeDiff.setStartTime() at the start of your script and call timeDiff.getDiff() at the end. The timeDiff.getDiff() function will return the script execution time.
Visit http://franca.exofire.net/jq/ for more JavaScript tips.