Module: Perfgate::Comparison::DeterministicMetricDecision

Defined in:
lib/perfgate/comparison/deterministic_metric_decision.rb

Overview

Deterministic decision path used for count-like metrics (currently only sql_count): no statistical test is applied, since query counts don't carry the same run-to-run noise that timing and allocation metrics do (spec section 16.3).

Class Method Summary collapse

Class Method Details

.call(metric, baseline_samples, candidate_samples, config) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/perfgate/comparison/deterministic_metric_decision.rb', line 14

def call(metric, baseline_samples, candidate_samples, config)
  change = MetricChange.summarize(metric, baseline_samples, candidate_samples)
  thresholds = config.dig(:comparison, :practical_thresholds, metric.to_sym) || {}
  decision = verdict(change, thresholds)

  MetricChange.result(change, confidence: nil, practically_significant: decision != "pass", noisy: false,
                              decision: decision)
end

.verdict(change, thresholds) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/perfgate/comparison/deterministic_metric_decision.rb', line 23

def verdict(change, thresholds)
  warning_absolute = thresholds[:warning_absolute] || 0
  failure_percent = thresholds[:failure_percent] || Float::INFINITY

  return "pass" if change[:absolute_change] <= 0
  return "pass" if change[:absolute_change] < warning_absolute

  change[:change_percent] >= failure_percent ? "fail" : "warn"
end