Skip to content

Commit

Permalink
refactor: use % threshold for duration diff (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski authored Oct 28, 2024
1 parent d69abb3 commit 780f4f3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/compare/src/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 780f4f3

Please sign in to comment.