logger.measure should return a similar function, that takes a timestamp before and after invoking the original function, printing the time (colorfully) it took to run
EXAMPLE:
function measureFunction(fn) {
return function () {
const start = performance.now();
const result = fn.call(this, arguments);
const stop = performance.now();
console.log('' + fn.name + '(...) took ' + (stop - start) + 'ms to run');
return result;
};
}
function stringifyAndUndo(obj) {
let objAsString = JSON.stringify(obj);
let backToObj = JSON.parse(objAsString);
return backToObj;
}
const measuredFunction = measureFunction(stringifyAndUndo);
const result = measuredFunction(
{ hello: 'world', travelTo: 'mars' }
);
logger.measureshould return a similar function, that takes a timestamp before and after invoking the original function, printing the time (colorfully) it took to runEXAMPLE: