Created
November 16, 2015 16:06
-
-
Save wonzbak/2d91cc3b50ccef5486fd to your computer and use it in GitHub Desktop.
This file contains 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 = function(name) { | |
var start = new Date(); | |
return { | |
stop: function() { | |
var end = new Date(); | |
var time = end.getTime() - start.getTime(); | |
console.log('Timer:', name, 'finished in', time, 'ms'); | |
} | |
} | |
}; | |
var t = timer('Some label'); | |
// code to benchmark | |
t.stop(); // prints the time elapsed to the js console |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment