Skip to content

Commit

Permalink
refactor: πŸ’‘ [KonvaTimeLine] PerformanceCheck function refactor
Browse files Browse the repository at this point in the history
βœ… Closes: #130
  • Loading branch information
CrisGrud committed Oct 26, 2023
1 parent b6f2c44 commit ba3ddc2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { DateTime } from "luxon";
import { logDebug } from "./logger";

export const executeWithPerfomanceCheck = <T>(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;
};

0 comments on commit ba3ddc2

Please sign in to comment.