diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 8be0ed1..f64347a 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -3,11 +3,14 @@ import { DateTime } from "luxon"; import { logDebug } from "./logger"; export const executeWithPerfomanceCheck = (tag: string, item: string, fn: () => T): T => { - logDebug(tag, `Running ${item}`); - const start = DateTime.now().toMillis(); + if (window.__MELFORE_KONVA_TIMELINE_DEBUG__) { + logDebug(tag, `Running ${item}`); + const start = DateTime.now().toMillis(); + const fnResult = fn(); + const end = DateTime.now().toMillis(); + logDebug(tag, `${item} calculation took ${end - start} ms`); + return fnResult; + } const result = fn(); - const end = DateTime.now().toMillis(); - - logDebug(tag, `${item} calculation took ${end - start} ms`); return result; };