Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use % threshold for duration diff #541

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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