Open History to see the last commit
1#!/usr/bin/env bun
2/**
3 * benchmark-session-ramp.ts — Benchmark 1: Session Count Ramp.
4 *
5 * Sweeps session count from 5 to 200 to find where Node's event loop
6 * degrades while Elixir stays stable. Runs 3 times per step (takes median).
7 *
8 * Usage:
9 * bun run scripts/benchmark-session-ramp.ts --runtime=node
10 * bun run scripts/benchmark-session-ramp.ts --runtime=elixir
11 * bun run scripts/benchmark-session-ramp.ts --runtime=node --steps=5,10,20
12 */
13
14import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
15import readline from "node:readline";
16import { writeFileSync, mkdirSync } from "node:fs";
17import v8 from "node:v8";
18
19let HarnessClientManager: any;
20try {
21 const mod = await import("../apps/server/src/provider/Layers/HarnessClientManager.ts");
22 HarnessClientManager = mod.HarnessClientManager;
23} catch {}
24
25// ---------------------------------------------------------------------------
26// Config
27// ---------------------------------------------------------------------------
28
29const OUTPUT_DIR = `${process.cwd()}/output/stress-test`;
30const RUNTIME = process.argv.find((a) => a.startsWith("--runtime="))?.split("=")[1] || "node";
31const HARNESS_PORT = Number(process.env.T3CODE_HARNESS_PORT ?? 4321);
32const HARNESS_SECRET = process.env.T3CODE_HARNESS_SECRET ?? "dev-harness-secret";
33
34const DEFAULT_STEPS = [5, 10, 20, 30, 50, 75, 100, 150, 200];
35const stepsArg = process.argv.find((a) => a.startsWith("--steps="))?.split("=")[1];
36const STEPS: number[] = stepsArg ? stepsArg.split(",").map(Number) : DEFAULT_STEPS;
37
38const RUNS_PER_STEP = 3;
39const DELTA_COUNT = 100;
40const DELTA_SIZE_KB = 1;
41const DELAY_MS = 10;
42const COOLDOWN_MS = 5000;
43
44mkdirSync(OUTPUT_DIR, { recursive: true });
45
46const t0 = Date.now();
47const ts = () => `+${((Date.now() - t0) / 1000).toFixed(1)}s`;
48const log = (msg: string) => console.log(` ${ts()} ${msg}`);
49
50function sleep(ms: number): Promise<void> {
51 return new Promise((r) => setTimeout(r, ms));
52}
53
54function percentile(arr: number[], p: number): number {
55 if (arr.length === 0) return 0;
56 const sorted = [...arr].sort((a, b) => a - b);
57 return sorted[Math.max(0, Math.ceil((p / 100) * sorted.length) - 1)]!;
58}
59
60function median(values: number[]): number {
61 if (values.length === 0) return 0;
62 const sorted = [...values].sort((a, b) => a - b);
63 return sorted[Math.floor(sorted.length / 2)]!;
64}
65
66function medianNullable(values: (number | null)[]): number | null {
67 const nums = values.filter((v): v is number => v !== null);
68 if (nums.length === 0) return null;
69 return median(nums);
70}
71
72// ---------------------------------------------------------------------------
73// Types
74// ---------------------------------------------------------------------------
75
76interface SessionStats {
77 id: string;
78 deltaCount: number;
79 turnsCompleted: number;
80 firstDeltaAt: number | null;
81 lastDeltaAt: number | null;
82 errors: string[];
83}
84
85function createStats(id: string): SessionStats {
86 return {
87 id,
88 deltaCount: 0,
89 turnsCompleted: 0,
90 firstDeltaAt: null,
91 lastDeltaAt: null,
92 errors: [],
93 };
94}
95
96interface RunMetrics {
97 memory_bytes: number;
98 per_session_memory_bytes: number | null;
99 latency_p50_ms: number;
100 latency_p99_ms: number;
101 throughput_events_per_sec: number;
102 event_loop_lag_p99_ms: number | null;
103 scheduler_util_avg: number | null;
104 correctness_pct: number;
105 startup_ms: number;
106}
107
108interface TimeSeriesPoint {
109 elapsed_ms: number;
110 [key: string]: number;
111}
112
113interface BenchmarkStep {
114 benchmark: string;
115 runtime: "node" | "elixir";
116 step: number;
117 stepLabel: string;
118 metrics: RunMetrics;
119 timeSeries: TimeSeriesPoint[];
120}
121
122// ---------------------------------------------------------------------------
123// Node runtime — N child processes
124// ---------------------------------------------------------------------------
125
126async function runNodeStep(
127 N: number,
128): Promise<{ metrics: RunMetrics; timeSeries: TimeSeriesPoint[] }> {
129 const allStats: SessionStats[] = [];
130 const eventTimestamps: number[] = [];
131
132 // Event loop lag
133 const lags: number[] = [];
134 let lastLagCheck = performance.now();
135 const lagTimer = setInterval(() => {
136 const now = performance.now();
137 const lag = now - lastLagCheck - 100;
138 if (lag > 5) lags.push(lag);
139 lastLagCheck = now;
140 }, 100);
141
142 const sessions = new Map<
143 string,
144 {
145 child: ChildProcessWithoutNullStreams;
146 rl: readline.Interface;
147 pending: Map<number, any>;
148 nextId: number;
149 codexThreadId: string | null;
150 }
151 >();
152
153 const startPhaseStart = Date.now();
154
155 for (let i = 0; i < N; i++) {
156 const sid = `ramp-node-${N}-${i}-${Date.now()}`;
157 const stats = createStats(sid);
158 allStats.push(stats);
159
160 const child = spawn(
161 "bun",
162 [
163 "run",
164 "scripts/mock-codex-server.ts",
165 String(DELTA_COUNT),
166 String(DELTA_SIZE_KB),
167 String(DELAY_MS),
168 "normal",
169 ],
170 { cwd: process.cwd(), env: process.env, stdio: ["pipe", "pipe", "pipe"] },
171 );
172
173 const rl = readline.createInterface({ input: child.stdout });
174 const session = {
175 child,
176 rl,
177 pending: new Map<number, any>(),
178 nextId: 1,
179 codexThreadId: null as string | null,
180 };
181 sessions.set(sid, session);
182
183 rl.on("line", (line: string) => {
184 try {
185 const msg = JSON.parse(line);
186 if (msg.id != null) {
187 const p = session.pending.get(msg.id);
188 if (p) {
189 session.pending.delete(msg.id);
190 p.resolve(msg.result ?? msg.error);
191 }
192 return;
193 }
194 if (msg.method === "item/agentMessage/delta") {
195 stats.deltaCount++;
196 const now = Date.now();
197 eventTimestamps.push(now);
198 if (!stats.firstDeltaAt) stats.firstDeltaAt = now;
199 stats.lastDeltaAt = now;
200 }
201 if (msg.method === "turn/completed") stats.turnsCompleted++;
202 } catch {}
203 });
204 child.stderr?.resume();
205
206 const rpc = (method: string, params: any) =>
207 new Promise<any>((resolve, reject) => {
208 const id = session.nextId++;
209 const timer = setTimeout(() => {
210 session.pending.delete(id);
211 reject(new Error("timeout"));
212 }, 30000);
213 session.pending.set(id, {
214 resolve: (v: any) => {
215 clearTimeout(timer);
216 resolve(v);
217 },
218 reject: (e: any) => {
219 clearTimeout(timer);
220 reject(e);
221 },
222 });
223 child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
224 });
225
226 try {
227 await rpc("initialize", { clientInfo: { name: "stress", version: "1.0" }, capabilities: {} });
228 child.stdin.write(JSON.stringify({ jsonrpc: "2.0", method: "initialized" }) + "\n");
229 const threadResult = await rpc("thread/start", { cwd: process.cwd() });
230 session.codexThreadId = threadResult?.thread?.id ?? null;
231 } catch (e) {
232 stats.errors.push(e instanceof Error ? e.message : String(e));
233 }
234
235 if ((i + 1) % 10 === 0) log(` ${i + 1}/${N} sessions started`);
236 }
237
238 const startupMs = Date.now() - startPhaseStart;
239
240 // Heap snapshot before sending
241 const preHeap = process.memoryUsage();
242
243 // Send turns to ALL simultaneously
244 for (const stats of allStats) {
245 const session = sessions.get(stats.id);
246 if (!session || stats.errors.length > 0) continue;
247
248 const rpc = (method: string, params: any) =>
249 new Promise<any>((resolve, reject) => {
250 const id = session.nextId++;
251 const timer = setTimeout(() => {
252 session.pending.delete(id);
253 reject(new Error("timeout"));
254 }, 60000);
255 session.pending.set(id, {
256 resolve: (v: any) => {
257 clearTimeout(timer);
258 resolve(v);
259 },
260 reject: (e: any) => {
261 clearTimeout(timer);
262 reject(e);
263 },
264 });
265 session.child.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
266 });
267
268 rpc("turn/start", {
269 threadId: session.codexThreadId,
270 input: [{ type: "text", text: "session-ramp test" }],
271 }).catch((e) => stats.errors.push(e instanceof Error ? e.message : String(e)));
272 }
273
274 // Wait for completion (max 120s), collect time series at 1s intervals
275 const streamStart = Date.now();
276 const end = streamStart + 120_000;
277 const timeSeries: TimeSeriesPoint[] = [];
278
279 while (Date.now() < end) {
280 const completed = allStats.filter((s) => s.turnsCompleted > 0).length;
281 const totalDeltas = allStats.reduce((s, st) => s + st.deltaCount, 0);
282 const mem = process.memoryUsage();
283
284 timeSeries.push({
285 elapsed_ms: Date.now() - streamStart,
286 heapUsed: mem.heapUsed,
287 rss: mem.rss,
288 completed,
289 totalDeltas,
290 });
291
292 if (
293 completed === allStats.length ||
294 allStats.every((s) => s.turnsCompleted > 0 || s.errors.length > 0)
295 )
296 break;
297 await sleep(1000);
298 }
299
300 clearInterval(lagTimer);
301
302 // Compute latencies from per-session durations
303 const sessionLatencies = allStats
304 .filter((s) => s.firstDeltaAt && s.lastDeltaAt)
305 .map((s) => s.lastDeltaAt! - s.firstDeltaAt!);
306
307 const totalDeltas = allStats.reduce((s, st) => s + st.deltaCount, 0);
308 const expectedDeltas = N * DELTA_COUNT;
309 const correctness = expectedDeltas > 0 ? (totalDeltas / expectedDeltas) * 100 : 0;
310
311 let throughput = 0;
312 if (eventTimestamps.length > 1) {
313 const streamDur = (eventTimestamps[eventTimestamps.length - 1]! - eventTimestamps[0]!) / 1000;
314 if (streamDur > 0) throughput = eventTimestamps.length / streamDur;
315 }
316
317 const postHeap = process.memoryUsage();
318
319 // Kill all child processes
320 for (const [, session] of sessions) {
321 try {
322 session.child.kill();
323 } catch {}
324 }
325
326 return {
327 metrics: {
328 memory_bytes: postHeap.rss,
329 per_session_memory_bytes: null,
330 latency_p50_ms: percentile(sessionLatencies, 50),
331 latency_p99_ms: percentile(sessionLatencies, 99),
332 throughput_events_per_sec: Math.round(throughput),
333 event_loop_lag_p99_ms: lags.length > 0 ? Math.round(percentile(lags, 99) * 10) / 10 : null,
334 scheduler_util_avg: null,
335 correctness_pct: Math.round(correctness * 10) / 10,
336 startup_ms: startupMs,
337 },
338 timeSeries,
339 };
340}
341
342// ---------------------------------------------------------------------------
343// Elixir runtime — N GenServer processes
344// ---------------------------------------------------------------------------
345
346async function runElixirStep(
347 N: number,
348 mgr: any,
349): Promise<{ metrics: RunMetrics; timeSeries: TimeSeriesPoint[] }> {
350 const allStats: SessionStats[] = [];
351 const eventTimestamps: number[] = [];
352 const METRICS_URL = `http://127.0.0.1:${HARNESS_PORT}/api/metrics`;
353
354 // Patch the mgr's onEvent to track our stats
355 const originalOnEvent = mgr._benchOnEvent;
356 mgr._benchOnEvent = (raw: any) => {
357 const stats = allStats.find((s) => s.id === raw.threadId);
358 if (!stats) return;
359 if (raw.method === "item/agentMessage/delta") {
360 stats.deltaCount++;
361 const now = Date.now();
362 eventTimestamps.push(now);
363 if (!stats.firstDeltaAt) stats.firstDeltaAt = now;
364 stats.lastDeltaAt = now;
365 }
366 if (raw.method === "turn/completed") stats.turnsCompleted++;
367 };
368
369 const startPhaseStart = Date.now();
370
371 for (let i = 0; i < N; i++) {
372 const sid = `ramp-elixir-${N}-${i}-${Date.now()}`;
373 const stats = createStats(sid);
374 allStats.push(stats);
375
376 try {
377 await mgr.startSession({
378 threadId: sid,
379 provider: "mock",
380 cwd: process.cwd(),
381 providerOptions: {
382 mock: { deltaCount: DELTA_COUNT, deltaSizeKb: DELTA_SIZE_KB, delayMs: DELAY_MS },
383 },
384 });
385 } catch (e) {
386 stats.errors.push(e instanceof Error ? e.message : String(e));
387 }
388
389 if ((i + 1) % 10 === 0) log(` ${i + 1}/${N} sessions started`);
390 }
391
392 const startupMs = Date.now() - startPhaseStart;
393
394 const preMetrics = (await fetch(METRICS_URL).then((r) => r.json())) as any;
395
396 // Send turns to ALL simultaneously
397 const turnPromises = allStats
398 .filter((s) => s.errors.length === 0)
399 .map((s) =>
400 mgr.sendTurn(s.id, { input: [{ type: "text", text: "session-ramp test" }] }).catch(() => {}),
401 );
402 await Promise.all(turnPromises);
403
404 // Wait for completion, collect time series at 1s intervals
405 const streamStart = Date.now();
406 const end = streamStart + 120_000;
407 const timeSeries: TimeSeriesPoint[] = [];
408
409 while (Date.now() < end) {
410 const completed = allStats.filter((s) => s.turnsCompleted > 0).length;
411 const totalDeltas = allStats.reduce((s, st) => s + st.deltaCount, 0);
412
413 try {
414 const m = (await fetch(METRICS_URL).then((r) => r.json())) as any;
415 timeSeries.push({
416 elapsed_ms: Date.now() - streamStart,
417 total_memory: m.beam?.total_memory ?? 0,
418 process_count: m.beam?.process_count ?? 0,
419 completed,
420 totalDeltas,
421 });
422 } catch {
423 timeSeries.push({ elapsed_ms: Date.now() - streamStart, completed, totalDeltas });
424 }
425
426 if (completed >= N || allStats.every((s) => s.turnsCompleted > 0 || s.errors.length > 0)) break;
427 await sleep(1000);
428 }
429
430 // Final metrics
431 const postMetrics = (await fetch(METRICS_URL).then((r) => r.json())) as any;
432 const sessionData = (postMetrics.sessions ?? [])
433 .filter((s: any) => String(s.thread_id ?? "").includes(`ramp-elixir-${N}`))
434 .map((s: any) => ({ memory: s.memory, gc_count: s.gc_count, reductions: s.reductions }));
435
436 // Compute latencies from per-session durations
437 const sessionLatencies = allStats
438 .filter((s) => s.firstDeltaAt && s.lastDeltaAt)
439 .map((s) => s.lastDeltaAt! - s.firstDeltaAt!);
440
441 const totalDeltas = allStats.reduce((s, st) => s + st.deltaCount, 0);
442 const expectedDeltas = N * DELTA_COUNT;
443 const correctness = expectedDeltas > 0 ? (totalDeltas / expectedDeltas) * 100 : 0;
444
445 let throughput = 0;
446 if (eventTimestamps.length > 1) {
447 const streamDur = (eventTimestamps[eventTimestamps.length - 1]! - eventTimestamps[0]!) / 1000;
448 if (streamDur > 0) throughput = eventTimestamps.length / streamDur;
449 }
450
451 const perSessionMemory =
452 sessionData.length > 0
453 ? sessionData.reduce((s: number, m: any) => s + m.memory, 0) / sessionData.length
454 : null;
455
456 let schedulerUtilAvg: number | null = null;
457 if (postMetrics?.beam?.scheduler_utilization) {
458 const sched = postMetrics.beam.scheduler_utilization;
459 if (Array.isArray(sched) && sched.length > 0) {
460 schedulerUtilAvg =
461 Math.round((sched.reduce((s: number, u: number) => s + u, 0) / sched.length) * 1000) / 1000;
462 }
463 }
464
465 // Cleanup sessions for this step
466 try {
467 await mgr.stopAll();
468 } catch {}
469
470 return {
471 metrics: {
472 memory_bytes: postMetrics.beam?.total_memory ?? 0,
473 per_session_memory_bytes: perSessionMemory,
474 latency_p50_ms: percentile(sessionLatencies, 50),
475 latency_p99_ms: percentile(sessionLatencies, 99),
476 throughput_events_per_sec: Math.round(throughput),
477 event_loop_lag_p99_ms: null,
478 scheduler_util_avg: schedulerUtilAvg,
479 correctness_pct: Math.round(correctness * 10) / 10,
480 startup_ms: startupMs,
481 },
482 timeSeries,
483 };
484}
485
486// ---------------------------------------------------------------------------
487// Median aggregation across runs
488// ---------------------------------------------------------------------------
489
490function medianMetrics(runs: RunMetrics[]): RunMetrics {
491 return {
492 memory_bytes: median(runs.map((r) => r.memory_bytes)),
493 per_session_memory_bytes: medianNullable(runs.map((r) => r.per_session_memory_bytes)),
494 latency_p50_ms: median(runs.map((r) => r.latency_p50_ms)),
495 latency_p99_ms: median(runs.map((r) => r.latency_p99_ms)),
496 throughput_events_per_sec: median(runs.map((r) => r.throughput_events_per_sec)),
497 event_loop_lag_p99_ms: medianNullable(runs.map((r) => r.event_loop_lag_p99_ms)),
498 scheduler_util_avg: medianNullable(runs.map((r) => r.scheduler_util_avg)),
499 correctness_pct: median(runs.map((r) => r.correctness_pct)),
500 startup_ms: median(runs.map((r) => r.startup_ms)),
501 };
502}
503
504// ---------------------------------------------------------------------------
505// Main
506// ---------------------------------------------------------------------------
507
508async function main() {
509 console.log("\n" + "╔" + "═".repeat(58) + "╗");
510 console.log("║" + ` Benchmark 1: Session Count Ramp — ${RUNTIME}`.padEnd(58) + "║");
511 console.log("║" + ` Steps: [${STEPS.join(", ")}]`.padEnd(58) + "║");
512 console.log(
513 "║" +
514 ` ${RUNS_PER_STEP} runs/step × ${DELTA_COUNT} deltas × ${DELTA_SIZE_KB}KB`.padEnd(58) +
515 "║",
516 );
517 console.log("╚" + "═".repeat(58) + "╝\n");
518
519 const results: BenchmarkStep[] = [];
520
521 // For Elixir, create and reuse a single manager across all steps
522 let elixirMgr: any = null;
523 if (RUNTIME === "elixir") {
524 elixirMgr = new HarnessClientManager({
525 harnessPort: HARNESS_PORT,
526 harnessSecret: HARNESS_SECRET,
527 onEvent: (raw: any) => {
528 // Delegate to the step-specific handler
529 if (elixirMgr._benchOnEvent) elixirMgr._benchOnEvent(raw);
530 },
531 onSessionChanged: () => {},
532 onDisconnect: () => {},
533 onReconnect: () => {},
534 });
535 await elixirMgr.connect();
536 log("Connected to harness (reusing connection across steps)");
537 }
538
539 for (const N of STEPS) {
540 console.log("\n" + "─".repeat(60));
541 console.log(` Step: ${N} sessions`);
542 console.log("─".repeat(60));
543
544 const runResults: { metrics: RunMetrics; timeSeries: TimeSeriesPoint[] }[] = [];
545
546 for (let run = 1; run <= RUNS_PER_STEP; run++) {
547 log(`Run ${run}/${RUNS_PER_STEP} with N=${N}...`);
548
549 let result: { metrics: RunMetrics; timeSeries: TimeSeriesPoint[] };
550 if (RUNTIME === "elixir") {
551 result = await runElixirStep(N, elixirMgr);
552 } else {
553 result = await runNodeStep(N);
554 }
555
556 runResults.push(result);
557
558 // Log run metrics
559 const m = result.metrics;
560 log(
561 ` Run ${run} done: correctness=${m.correctness_pct}% throughput=${m.throughput_events_per_sec}ev/s startup=${m.startup_ms}ms`,
562 );
563 if (m.event_loop_lag_p99_ms !== null)
564 log(` Event loop lag p99: ${m.event_loop_lag_p99_ms}ms`);
565 if (m.scheduler_util_avg !== null)
566 log(` Scheduler util avg: ${(m.scheduler_util_avg * 100).toFixed(1)}%`);
567 if (m.per_session_memory_bytes !== null)
568 log(` Per-session memory: ${(m.per_session_memory_bytes / 1024).toFixed(1)}KB`);
569
570 // Cooldown between runs
571 if (run < RUNS_PER_STEP) {
572 log(` Cooling down ${COOLDOWN_MS / 1000}s...`);
573 await sleep(COOLDOWN_MS);
574 }
575 }
576
577 // Take median across runs
578 const medianRun = medianMetrics(runResults.map((r) => r.metrics));
579
580 // Use the time series from the median run (run with median throughput)
581 const throughputs = runResults.map((r) => r.metrics.throughput_events_per_sec);
582 const medianThroughput = median(throughputs);
583 const medianIdx = throughputs.indexOf(
584 throughputs.reduce((closest, v) =>
585 Math.abs(v - medianThroughput) < Math.abs(closest - medianThroughput) ? v : closest,
586 ),
587 );
588 const medianTimeSeries = runResults[medianIdx >= 0 ? medianIdx : 0]!.timeSeries;
589
590 const step: BenchmarkStep = {
591 benchmark: "session-ramp",
592 runtime: RUNTIME as "node" | "elixir",
593 step: N,
594 stepLabel: `${N} sessions`,
595 metrics: medianRun,
596 timeSeries: medianTimeSeries,
597 };
598
599 results.push(step);
600
601 // Summary for this step
602 console.log(
603 `\n ▸ Median (N=${N}): throughput=${medianRun.throughput_events_per_sec}ev/s latency_p50=${medianRun.latency_p50_ms}ms p99=${medianRun.latency_p99_ms}ms correctness=${medianRun.correctness_pct}%`,
604 );
605 console.log(
606 ` memory=${(medianRun.memory_bytes / 1024 / 1024).toFixed(1)}MB startup=${medianRun.startup_ms}ms`,
607 );
608
609 // Cooldown between steps
610 if (N !== STEPS[STEPS.length - 1]) {
611 log(`Cooling down ${COOLDOWN_MS / 1000}s before next step...`);
612 await sleep(COOLDOWN_MS);
613 }
614 }
615
616 // Disconnect Elixir manager after all steps
617 if (elixirMgr) {
618 elixirMgr.disconnect();
619 log("Disconnected from harness");
620 }
621
622 // Write output
623 const filename = `benchmark-session-ramp-${RUNTIME}-${Date.now()}.json`;
624 writeFileSync(`${OUTPUT_DIR}/${filename}`, JSON.stringify(results, null, 2));
625
626 // Final summary table
627 console.log("\n\n" + "═".repeat(60));
628 console.log(" SESSION RAMP BENCHMARK — FINAL RESULTS");
629 console.log("═".repeat(60));
630 console.log(
631 ` ${"Step".padEnd(8)} ${"Tput".padStart(8)} ${"P50".padStart(8)} ${"P99".padStart(8)} ${"Lag99".padStart(8)} ${"Mem MB".padStart(8)} ${"Corr%".padStart(8)}`,
632 );
633 console.log(" " + "─".repeat(56));
634
635 for (const step of results) {
636 const m = step.metrics;
637 const lagStr =
638 m.event_loop_lag_p99_ms !== null
639 ? `${m.event_loop_lag_p99_ms}`
640 : m.scheduler_util_avg !== null
641 ? `${(m.scheduler_util_avg * 100).toFixed(1)}%`
642 : "n/a";
643 console.log(
644 ` ${String(step.step).padEnd(8)} ${String(m.throughput_events_per_sec).padStart(8)} ${String(m.latency_p50_ms).padStart(8)} ${String(m.latency_p99_ms).padStart(8)} ${lagStr.padStart(8)} ${(m.memory_bytes / 1024 / 1024).toFixed(1).padStart(8)} ${String(m.correctness_pct).padStart(8)}`,
645 );
646 }
647
648 console.log("═".repeat(60));
649 log(`Results written to ${OUTPUT_DIR}/${filename}`);
650
651 setTimeout(() => process.exit(0), 2000);
652}
653
654main().catch((err) => {
655 console.error("Fatal:", err);
656 process.exit(1);
657});