I just thought I'd share this little snippet I put together last night...
A (very) simple JavaScript timer object. I use it to help me measure how long scripts take to execute...
timer.start(); // starts counting
timer.since(); // returns elapsed time in milliseconds
The code:
Code:
var timer = {
time: 0,
now: function(){ return (new Date()).getTime(); },
start: function(){ this.time = this.now(); },
since: function(){ return this.now()-this.time; }
}
As posted on my new blog:
Javascript Timer.