(baselineRunRaw, currentRunRaw, config, options = {})
| 527 | } |
| 528 | |
| 529 | export function compareBenchRuns(baselineRunRaw, currentRunRaw, config, options = {}) { |
| 530 | const baselineRun = normalizeBenchRun(baselineRunRaw, "baseline"); |
| 531 | const currentRun = normalizeBenchRun(currentRunRaw, "current"); |
| 532 | const baselineIndex = indexBenchResults(baselineRun, "baseline"); |
| 533 | const currentIndex = indexBenchResults(currentRun, "current"); |
| 534 | |
| 535 | const metricPaths = [...config.defaultRules.keys()].sort(); |
| 536 | const checks = []; |
| 537 | |
| 538 | for (const req of config.requiredScenarios) { |
| 539 | const baselineResult = baselineIndex.get(req.key) ?? null; |
| 540 | const currentResult = currentIndex.get(req.key) ?? null; |
| 541 | |
| 542 | if (!baselineResult) { |
| 543 | for (const metric of metricPaths) { |
| 544 | checks.push( |
| 545 | buildMissingResultCheck( |
| 546 | req, |
| 547 | metric, |
| 548 | STATUS.MISSING_BASELINE_RESULT, |
| 549 | "required scenario missing from baseline results", |
| 550 | ), |
| 551 | ); |
| 552 | } |
| 553 | continue; |
| 554 | } |
| 555 | if (!currentResult) { |
| 556 | for (const metric of metricPaths) { |
| 557 | checks.push( |
| 558 | buildMissingResultCheck( |
| 559 | req, |
| 560 | metric, |
| 561 | STATUS.MISSING_CURRENT_RESULT, |
| 562 | "required scenario missing from current results", |
| 563 | ), |
| 564 | ); |
| 565 | } |
| 566 | continue; |
| 567 | } |
| 568 | |
| 569 | for (const metric of metricPaths) { |
| 570 | const resolved = resolveRule(config, { |
| 571 | scenario: req.scenario, |
| 572 | framework: req.framework, |
| 573 | params: req.params, |
| 574 | metric, |
| 575 | }); |
| 576 | if (!resolved) continue; |
| 577 | |
| 578 | const baselineValue = getMetricValue(baselineResult.metrics, metric); |
| 579 | const currentValue = getMetricValue(currentResult.metrics, metric); |
| 580 | |
| 581 | if (baselineValue === null) { |
| 582 | checks.push({ |
| 583 | scenario: req.scenario, |
| 584 | framework: req.framework, |
| 585 | params: req.params, |
| 586 | metric, |
no test coverage detected