Created
October 10, 2010 03:24
-
-
Save muratcorlu/618898 to your computer and use it in GitHub Desktop.
Simple timer with javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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