I am getting an error ReferenceError: performance is not defined
when trying to use performance.now() to measure the execution time of a function call:
export async function find(someId: string, ctx: context.IContext) {
try {
var t0 = performance.now();
var res = someModel.find(someId, ctx.cookies);
var t1 = performance.now();
console.log("Call to find took " + (t1 - t0) + " milliseconds.");
return res;
} catch (err) {
console.error(err);
throw err;
}
}
Any ideas how I can fix this?
window.performance
. I'm guessing typescript is trying to limit the scope of the performance variable when it compiles. – Amytal