MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / run

Function run

packages/cli/src/commands/benchmark.ts:59–244  ·  view source on GitHub ↗
({ args })

Source from the content-addressed store, hash-verified

57 json: { type: "boolean", description: "Output results as JSON", default: false },
58 },
59 async run({ args }) {
60 // ── Resolve project ──────────────────────────────────────────────────
61 const project = resolveProject(args.dir);
62
63 // ── Parse runs ───────────────────────────────────────────────────────
64 const runsPerConfig = parseInt(args.runs ?? "3", 10);
65 if (isNaN(runsPerConfig) || runsPerConfig < 1 || runsPerConfig > 20) {
66 errorBox("Invalid runs", `Got "${args.runs ?? "3"}". Must be between 1 and 20.`);
67 process.exit(1);
68 }
69
70 const jsonOutput = args.json ?? false;
71
72 // ── Temp output for benchmark renders ────────────────────────────────
73 const benchDir = resolve("renders", ".benchmark");
74
75 // ── Load producer ────────────────────────────────────────────────────
76 let producer: Awaited<ReturnType<typeof loadProducer>> | null = null;
77 try {
78 producer = await loadProducer();
79 } catch {
80 if (jsonOutput) {
81 console.log(
82 JSON.stringify({ error: "Producer module not available. Is the project built?" }),
83 );
84 } else {
85 errorBox(
86 "Producer module not available",
87 "The rendering pipeline could not be loaded.",
88 "Ensure @hyperframes/producer is built and linked.",
89 );
90 }
91 process.exit(1);
92 }
93
94 // ── Print header ─────────────────────────────────────────────────────
95 if (!jsonOutput) {
96 console.log("");
97 console.log(
98 c.accent("\u25C6") +
99 " Benchmarking " +
100 c.accent(project.name) +
101 c.dim(` (${runsPerConfig} runs each)`),
102 );
103 console.log("");
104 }
105
106 // ── Run benchmarks ───────────────────────────────────────────────────
107 const results: ConfigResult[] = [];
108
109 for (const config of DEFAULT_CONFIGS) {
110 const runs: RunResult[] = [];
111 let failures = 0;
112
113 const s = !jsonOutput ? clack.spinner() : undefined;
114 s?.start(`Benchmarking ${config.label}...`);
115
116 for (let i = 0; i < runsPerConfig; i++) {

Callers

nothing calls this directly

Calls 13

fpsToFfmpegArgFunction · 0.90
errorBoxFunction · 0.85
resolveFunction · 0.85
loadProducerFunction · 0.85
withMetaFunction · 0.85
nowMethod · 0.80
warnMethod · 0.80
errorMethod · 0.80
resolveProjectFunction · 0.50
formatDurationFunction · 0.50
formatBytesFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected