Skip to content

Instantly share code, notes, and snippets.

@wonzbak
Created November 16, 2015 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonzbak/2d91cc3b50ccef5486fd to your computer and use it in GitHub Desktop.
Save wonzbak/2d91cc3b50ccef5486fd to your computer and use it in GitHub Desktop.
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