const flag = (process.env.NERF_STARTUP_TIMING ?? process.env.PI_TIMING ?? "").toLowerCase();
const ENABLED = flag === "1" || flag === "true" || flag === "yes";
const timings = [];
let lastTime = Date.now();
export function markStartup(label) {
    if (!ENABLED)
        return;
    const now = Date.now();
    timings.push({ label, ms: now - lastTime });
    lastTime = now;
}
export function printStartupTimings() {
    if (!ENABLED || timings.length === 0)
        return;
    const total = timings.reduce((sum, timing) => sum + timing.ms, 0);
    process.stderr.write("\n--- NERF Startup Timings ---\n");
    for (const timing of timings) {
        process.stderr.write(`  ${timing.label}: ${timing.ms}ms\n`);
    }
    process.stderr.write(`  TOTAL: ${total}ms\n`);
    process.stderr.write("----------------------------\n\n");
}
