| 272 | } |
| 273 | |
| 274 | async function measure(testCase: BenchmarkCase): Promise<MeasureResult> { |
| 275 | const runs: ExplainResult[] = [] |
| 276 | for (let i = 0; i < RUNS; i++) { |
| 277 | runs.push(await explain(testCase.sql, testCase.params)) |
| 278 | } |
| 279 | const summaries = runs.map(summarize) |
| 280 | const exec = summaries.map((s) => s.execMs).sort((a, b) => a - b) |
| 281 | const median = exec[Math.floor(exec.length / 2)] |
| 282 | const min = exec[0] |
| 283 | const max = exec[exec.length - 1] |
| 284 | return { |
| 285 | indexes: summaries[0]?.indexes ?? [], |
| 286 | nodeTypes: summaries[0]?.nodeTypes ?? [], |
| 287 | min, |
| 288 | median, |
| 289 | max, |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | async function main(): Promise<void> { |
| 294 | await client.connect() |