Last active
August 29, 2015 13:56
-
-
Save pentaphobe/8932279 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
/** | |
* 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