( func: (...options: unknown[]) => T | Promise<T>, funcName: string, )
| 12 | funcName: string, |
| 13 | ): Promise<T>; |
| 14 | export 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 | |
| 35 | function logTiming(start: number, funcName: string): void { |
| 36 | const end = performance.now(); |
nothing calls this directly
no test coverage detected