( definition: WorkflowDefinition, iterations: number, label: BenchmarkMode, )
| 200 | } |
| 201 | |
| 202 | async function runInlineBenchmark( |
| 203 | definition: WorkflowDefinition, |
| 204 | iterations: number, |
| 205 | label: BenchmarkMode, |
| 206 | ): Promise<BenchmarkResult> { |
| 207 | const durations: number[] = []; |
| 208 | |
| 209 | for (let i = 0; i < iterations; i += 1) { |
| 210 | const runId = `${label}-inline-${randomUUID()}`; |
| 211 | const start = Date.now(); |
| 212 | |
| 213 | const result = await executeWorkflow(definition, {}, { runId }); |
| 214 | if (!result.success) { |
| 215 | throw new Error(`Inline benchmark ${label} failed: ${result.error}`); |
| 216 | } |
| 217 | |
| 218 | durations.push(Date.now() - start); |
| 219 | } |
| 220 | |
| 221 | const averageMs = durations.reduce((sum, value) => sum + value, 0) / durations.length; |
| 222 | |
| 223 | return { |
| 224 | engine: 'inline', |
| 225 | mode: label, |
| 226 | runs: iterations, |
| 227 | durations, |
| 228 | averageMs, |
| 229 | }; |
| 230 | } |
| 231 | |
| 232 | async function main() { |
| 233 | const iterations = Number.parseInt(process.env.BENCHMARK_ITERATIONS ?? '3', 10); |
no test coverage detected