Last active
December 30, 2015 05:29
-
-
Save jschomay/7782774 to your computer and use it in GitHub Desktop.
functional util to make a function time itself
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
// functional util to make a function time itself | |
function makeTimedFunction(fn, lable) { | |
return function(){ | |
console.time(lable || 'time to complete '+fn.name); | |
var results = fn.apply(fn,Array.prototype.slice.call(arguments)); | |
console.timeEnd(lable || 'time to complete '+fn.name); | |
return results; | |
}; | |
} |
updated to pass along the results of the original function
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to pass along the results of the original function