Skip to content

Commit

Permalink
Merge pull request #46732 from margelo/e2e/lower-is-better
Browse files Browse the repository at this point in the history
[NoQA] e2e: add `lowerIsBetter` for e2e metrics
  • Loading branch information
Julesssss authored Aug 5, 2024
2 parents 66ae374 + 83e36dd commit 40a6c76
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/e2e/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ const PROBABILITY_CONSIDERED_SIGNIFICANCE = 0.02;
*/
const DURATION_DIFF_THRESHOLD_SIGNIFICANCE = 100;

const LowerIsBetter: Record<Unit, boolean> = {
ms: true,
MB: true,
// eslint-disable-next-line @typescript-eslint/naming-convention
'%': true,
renders: true,
FPS: false,
};

function buildCompareEntry(name: string, compare: Stats, baseline: Stats, unit: Unit): Entry {
const diff = compare.mean - baseline.mean;
const relativeDurationDiff = diff / baseline.mean;
Expand All @@ -44,7 +53,7 @@ function buildCompareEntry(name: string, compare: Stats, baseline: Stats, unit:
baseline,
current: compare,
diff,
relativeDurationDiff,
relativeDurationDiff: LowerIsBetter[unit] ? relativeDurationDiff : -relativeDurationDiff,
isDurationDiffOfSignificance,
};
}
Expand Down

0 comments on commit 40a6c76

Please sign in to comment.