Skip to content

Instantly share code, notes, and snippets.

@fson
Last active December 29, 2015 23:59
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 fson/7746937 to your computer and use it in GitHub Desktop.
Save fson/7746937 to your computer and use it in GitHub Desktop.
function timeit(fn) {
console.time(fn.name);
fn.apply(null, [].slice.call(arguments, 1).map(function (arg) {
if (arg === timeit.done) return function () { console.timeEnd(fn.name); }
else return arg;
}));
}
timeit.done = function () {};
@fson
Copy link
Author

fson commented Feb 17, 2014

To time the function call

myFun(arg1, arg2, callback)

just call

timeit(myFun, arg1, arg2, timeit.done);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment