Skip to content

Commit

Permalink
Add isSignificant to result. (#4030)
Browse files Browse the repository at this point in the history
If the change is not significant, it will be zero. Else
Cliffs delta is used to determine how large the change is.

In Graphite we could then alert on everything > 0. And then match
Cliffs delta to tell us if the change is small, medium or large.
  • Loading branch information
soulgalore authored Dec 15, 2023
1 parent 26e6005 commit 0039afb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/plugins/compare/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ export function getMetrics(data) {
};
}

export function getIsSignificant(u, cliffs) {
return u < 0.05 ? cliffs : 0;
}

export function cliffsDelta(x, y) {
const n_x = x.length;
const n_y = y.length;
Expand Down
18 changes: 15 additions & 3 deletions lib/plugins/compare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
getStatistics,
runStatisticalTests,
getMetrics,
cliffsDelta
cliffsDelta,
getIsSignificant
} from './helper.js';
import { getBaseline, saveBaseline } from './baseline.js';

Expand Down Expand Up @@ -39,7 +40,16 @@ const DEFAULT_METRICS_PAGESUMMARY = [
'metrics.renderBlocking.*.statisticalTestU',
'metrics.elementTimings.*.statisticalTestU',
'metrics.userTimings.*.statisticalTestU',
'metrics.extras.*.statisticalTestU'
'metrics.extras.*.statisticalTestU',
'metrics.timings.*.isSignificant',
'metrics.cpu.*.isSignificant',
'metrics.cdp.*.isSignificant',
'metrics.visualMetrics.*.isSignificant',
'metrics.googleWebVitals.*.isSignificant',
'metrics.renderBlocking.*.isSignificant',
'metrics.elementTimings.*.isSignificant',
'metrics.userTimings.*.isSignificant',
'metrics.extras.*.isSignificant'
];

export default class ComparePlugin extends SitespeedioPlugin {
Expand Down Expand Up @@ -174,6 +184,7 @@ export default class ComparePlugin extends SitespeedioPlugin {
baselineMetrics[group][metricName].getValues()
);

const cliffs = cliffsDelta(currentStats.data, baselineStats.data);
finalResult[group][metricName] = {
current: {
stdev: currentStats.stddev(),
Expand All @@ -188,7 +199,8 @@ export default class ComparePlugin extends SitespeedioPlugin {
values: baselineStats.data
},
statisticalTestU: result['p-value'],
cliffsDelta: cliffsDelta(currentStats.data, baselineStats.data)
cliffsDelta: cliffs,
isSignificant: getIsSignificant(result['p-value'], cliffs)
};
}
}
Expand Down

0 comments on commit 0039afb

Please sign in to comment.