export async function timed( label: string, fn: () => Promise, ): Promise { const start = Date.now(); try { const result = await fn(); const ms = Date.now() - start; console.log(`[timing] ${label} ok in ${ms}ms`); return result; } catch (err) { const ms = Date.now() - start; const msg = err instanceof Error ? err.message : String(err); console.log(`[timing] ${label} FAILED in ${ms}ms: ${msg}`); throw err; } }