singularity-forge/src/startup-timings.ts
Mikael Hugo b24f426f2b batch: snapshot of in-flight v2 work
This commit captures uncommitted modifications that accumulated in the
working tree across multiple in-progress workstreams. It is a snapshot
to clear the deck before sf v3 work begins; individual workstreams
should land separately on top of this.

Notable additions:
- trace-collector.ts, traces.ts, src/tests/trace-export.test.ts —
  trace export plumbing
- biome.json — Biome linter configuration
- .gitignore — exclude native/npm/**/*.node compiled binaries

The bulk of the diff is across src/resources/extensions/sf/ (301 files)
and src/resources/extensions/sf/tests/ (277 files), reflecting the
ongoing sf extension work. Specific feature commits should follow this
snapshot rather than being archaeology'd out of it.

The 76MB native/npm/linux-x64-gnu/forge_engine.node compiled binary
was left out of the commit — it's now gitignored and built locally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 12:42:31 +02:00

27 lines
841 B
TypeScript

const flag = (
process.env.SF_STARTUP_TIMING ??
process.env.PI_TIMING ??
""
).toLowerCase();
const ENABLED = flag === "1" || flag === "true" || flag === "yes";
const timings: Array<{ label: string; ms: number }> = [];
let lastTime = Date.now();
export function markStartup(label: string): void {
if (!ENABLED) return;
const now = Date.now();
timings.push({ label, ms: now - lastTime });
lastTime = now;
}
export function printStartupTimings(): void {
if (!ENABLED || timings.length === 0) return;
const total = timings.reduce((sum, timing) => sum + timing.ms, 0);
process.stderr.write("\n--- SF 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");
}