Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

benchmark-runner-cli.ts

55 lines1.8 KB

1/**
2 * Pure CLI parsing and benchmark list selection for benchmark-runner.ts.
3 */
4​
5export const BENCHMARK_SUITE = [
6 { name: "session-ramp", script: "benchmark-session-ramp.ts", quickSteps: "5,10,20" },
7 { name: "payload-ramp", script: "benchmark-payload-ramp.ts", quickSteps: "0.1,1,10" },
8 { name: "subagent-ramp", script: "benchmark-subagent-ramp.ts", quickSteps: "1,3,5" },
9 { name: "failure-storm", script: "benchmark-failure-storm.ts", quickSteps: "0,1,5" },
10 { name: "sustained-leak", script: "benchmark-sustained-leak.ts", quickSteps: "1,5" },
11] as const;
12​
13export type BenchmarkSuiteEntry = (typeof BENCHMARK_SUITE)[number];
14​
15export type ParsedBenchmarkRunnerArgv = {
16 runtime: string;
17 only: string[] | null;
18 skip: string[];
19 quick: boolean;
20};
21​
22export function parseBenchmarkRunnerArgv(argv: string[]): ParsedBenchmarkRunnerArgv {
23 const runtime = argv.find((a) => a.startsWith("--runtime="))?.split("=")[1] ?? "both";
24 const onlyRaw = argv.find((a) => a.startsWith("--only="))?.split("=")[1];
25 const only = onlyRaw
26 ? onlyRaw
27 .split(",")
28 .map((s) => s.trim())
29 .filter(Boolean)
30 : null;
31 const skipRaw =
32 argv
33 .find((a) => a.startsWith("--skip="))
34 ?.split("=")[1]
35 ?.split(",") ?? [];
36 const skip = skipRaw.map((s) => s.trim()).filter(Boolean);
37 const quick = argv.includes("--quick");
38 return { runtime, only, skip, quick };
40​
41export function expandRuntimes(runtime: string): string[] {
42 return runtime === "both" ? ["elixir", "node"] : [runtime];
44​
45export function filterBenchmarkSuite<T extends { name: string }>(
46 benchmarks: readonly T[],
47 only: string[] | null,
48 skip: string[],
49): T[] {
50 return benchmarks.filter((b) => {
51 if (only && !only.includes(b.name)) return false;
52 if (skip.includes(b.name)) return false;
53 return true;
54 });