Skip to content

Instantly share code, notes, and snippets.

@jschomay
Last active December 30, 2015 05:29
Show Gist options
  • Save jschomay/7782774 to your computer and use it in GitHub Desktop.
Save jschomay/7782774 to your computer and use it in GitHub Desktop.
functional util to make a function time itself
// 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;
};
}
@jschomay
Copy link
Author

jschomay commented Dec 5, 2013

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