#!/usr/bin/env node /** * Orca daemon cold-start benchmark (Windows-focused). * * Reproduces the "daemon was force-killed / machine rebooted" launch path: * every daemon pid file (current protocol + all legacy versions) is planted * pointing at a live unrelated process, simulating Windows pid recycling — * the case where `process.kill(pid, 0)` says alive and startup must spawn * PowerShell (Get-CimInstance) to disambiguate. Measures how long daemon init * takes and, critically, how long the Electron main thread stalls * (event-loop-stall probe) while pid identity checks run. * * Usage: * node tools/benchmarks/daemon-coldstart-bench.mjs --label baseline * [--iterations 3] [--linger-ms 15000] [--timeout-ms 240000] * [--exe ] * * Prereq (when not using --exe): `pnpm build:electron-vite` so out/ exists. * Results: tools/benchmarks/results/daemon-coldstart-