(scope: string)
| 15 | } |
| 16 | |
| 17 | export function createStartupProfiler(scope: string): StartupProfiler { |
| 18 | const enabled = isEnabled(); |
| 19 | const startedAtMs = performance.now(); |
| 20 | |
| 21 | return { |
| 22 | enabled, |
| 23 | startedAtMs, |
| 24 | mark(stage: string, stageStartedAtMs: number): void { |
| 25 | if (!enabled) return; |
| 26 | const elapsedMs = performance.now() - stageStartedAtMs; |
| 27 | const totalMs = performance.now() - startedAtMs; |
| 28 | log( |
| 29 | 'info', |
| 30 | `[startup-profile] scope=${scope} stage=${stage} ms=${elapsedMs.toFixed(1)} totalMs=${totalMs.toFixed(1)}`, |
| 31 | ); |
| 32 | }, |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | export function getStartupProfileNowMs(): number { |
| 37 | return performance.now(); |
no test coverage detected