Skip to content

Instantly share code, notes, and snippets.

@pentaphobe
Last active August 29, 2015 13:56
Show Gist options
  • Save pentaphobe/8932279 to your computer and use it in GitHub Desktop.
Save pentaphobe/8932279 to your computer and use it in GitHub Desktop.
/**
* A dodgy and simple profiler wrapping thingy
*
* It don't do much, but I whipped this up as a basic helper for a coworker so may as well store for later :)
*
*/
/**
* @param {Function} fn The function you wish to profile
* @param {Object} scope The 'this' property to bind
* @param {String=} message If specified, this will act as a prefix to a logged output
*/
function profile(fn, scope, message) {
var start = new Date(), delta;
fn.call(scope);
delta = new Date() - start;
if (message) {
console.log(message, delta);
}
return delta;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment