MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / debugFunctionExecutionTime

Function debugFunctionExecutionTime

frontend/src/ts/utils/debug.ts:14–33  ·  view source on GitHub ↗
(
  func: (...options: unknown[]) => T | Promise<T>,
  funcName: string,
)

Source from the content-addressed store, hash-verified

12 funcName: string,
13): Promise<T>;
14export function debugFunctionExecutionTime<T>(
15 func: (...options: unknown[]) => T | Promise<T>,
16 funcName: string,
17): T | Promise<T> {
18 const start = performance.now();
19 const ret = func();
20
21 // Check if the result is a Promise
22 if (ret instanceof Promise) {
23 // Handle async case
24 return ret.then((resolvedValue) => {
25 logTiming(start, funcName);
26 return resolvedValue;
27 });
28 } else {
29 // Handle sync case
30 logTiming(start, funcName);
31 return ret;
32 }
33}
34
35function logTiming(start: number, funcName: string): void {
36 const end = performance.now();

Callers

nothing calls this directly

Calls 1

logTimingFunction · 0.85

Tested by

no test coverage detected