Skip to content

Instantly share code, notes, and snippets.

@muratcorlu
Created October 10, 2010 03:24
Show Gist options
  • Save muratcorlu/618898 to your computer and use it in GitHub Desktop.
Save muratcorlu/618898 to your computer and use it in GitHub Desktop.
Simple timer with javascript
var timer = {
started: 0,
end: 0,
now: function(){ return new Date(); },
start: function(){ return this.started = this.now(); },
since: function(){ this.end = this.now(); return this.now()-this.started; }
}
// Usage:
console.log("Timer started at "+timer.start());
for(x=1;x<100000;x++){
// Something
}
console.log("Some process: " + timer.since() + "ms");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment