Skip to content

Commit

Permalink
fix(patch): Show exact deviations if rounded are zero (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassila authored Sep 14, 2023
1 parent 8e6ffd9 commit 6e0cdf8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Sources/Benchmark/BenchmarkResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ public struct BenchmarkResult: Codable, Comparable, Equatable {
let absoluteDifference = (reverseComparison ? -1 : 1) * (lhs - threshold)

if absoluteDifference != 0 {
let deviation = ThresholdDeviation(name: name,
let normalizedDifference = normalize(absoluteDifference)
let deviation: ThresholdDeviation
if normalizedDifference != 0 {
deviation = ThresholdDeviation(name: name,
target: target,
metric: metric,
percentile: percentile,
Expand All @@ -471,6 +474,18 @@ public struct BenchmarkResult: Codable, Comparable, Equatable {
differenceThreshold: normalize(absoluteDifference),
relative: false,
units: scalingFactor)
} else {
deviation = ThresholdDeviation(name: name,
target: target,
metric: metric,
percentile: percentile,
baseValue: lhs,
comparisonValue: threshold,
difference: absoluteDifference,
differenceThreshold: absoluteDifference,
relative: false,
units: .count)
}
if absoluteDifference < 0 {
thresholdResults.improvements.append(deviation)
} else {
Expand Down

0 comments on commit 6e0cdf8

Please sign in to comment.