A wrapper for any functions you wish to time.
npm i wrap-function-timer
Pass the function and any of its parameters into the 'time' method. We also pass in a variable which tells our timer whether or not to time the function. We return the results with the 'report' method which will then reset the stored times.
For example:
const timer = require('wrap-function-timer');
const myFunction = (args) => {
console.log('I am about to be timed!');
console.log('some functionality', args);
};
// regular invocation of function
myFunction(arg1, arg2, ...)
// timed invocation of function
// enabled param can be used to turn timer on/off
timer.time(myFunction, enabled = true, arg1, arg2, ...);
timer.report();