From e884709c28264c60b67a2c962c1ab3c0a85873cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Mon, 28 Oct 2024 10:43:07 +0100 Subject: [PATCH] refactor: use % threshold for duration diff --- packages/compare/src/compare.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/compare/src/compare.ts b/packages/compare/src/compare.ts index 02601925..e4a87131 100644 --- a/packages/compare/src/compare.ts +++ b/packages/compare/src/compare.ts @@ -21,12 +21,10 @@ import { parseHeader, parseMeasureEntries } from './utils/validate'; const PROBABILITY_CONSIDERED_SIGNIFICANT = 0.02; /** - * Duration threshold (in ms) for treating given difference as significant. - * + * Duration threshold (in %) for treating given difference as significant. * This is additional filter, in addition to probability threshold above. - * Too small duration difference might be result of measurement grain of 1 ms. */ -const DURATION_DIFF_THRESHOLD_SIGNIFICANT = 4; +const MIN_SIGNIFICANT_PERCENT_DURATION_THRESHOLD = 0.05; // 5% /** * Threshold for considering render or execution count change as significant. This implies inclusion @@ -194,7 +192,8 @@ function buildCompareEntry(name: string, current: MeasureEntry, baseline: Measur const prob = computeProbability(z); const isDurationDiffSignificant = - prob < PROBABILITY_CONSIDERED_SIGNIFICANT && Math.abs(durationDiff) >= DURATION_DIFF_THRESHOLD_SIGNIFICANT; + prob < PROBABILITY_CONSIDERED_SIGNIFICANT && + Math.abs(relativeDurationDiff) >= MIN_SIGNIFICANT_PERCENT_DURATION_THRESHOLD; return { name,