Skip to content

Commit

Permalink
misc(lantern-collect): rebaseline to include new ttfb metric (#15069)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored May 11, 2023
1 parent fbf5af5 commit 49aa142
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ for (const entry of computedResults.sites) {
/** @type {DiffForSite[]} */
const diffsForSite = [];
Object.keys(actualLantern).forEach(metricName => {
if (!(metricName in expectedLantern)) throw new Error(`missing metric ${metricName}`);

const actual = Math.round(actualLantern[metricName]);
const expected = Math.round(expectedLantern[metricName]);
const diff = actual - expected;
Expand Down
10 changes: 10 additions & 0 deletions core/scripts/lantern/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import {LH_ROOT} from '../../../root.js';
* @property {number} [timeToConsistentlyInteractive]
* @property {number} [speedIndex]
* @property {number} [largestContentfulPaint]
* @property {number} [timeToFirstByte]
* @property {number} [largestContentfulPaintLoadStart]
* @property {number} [largestContentfulPaintLoadEnd]
*/

/**
Expand All @@ -67,6 +70,9 @@ import {LH_ROOT} from '../../../root.js';
* @property {number} roughEstimateOfSI
* @property {number} roughEstimateOfTTI
* @property {number} roughEstimateOfLCP
* @property {number} roughEstimateOfTTFB
* @property {number} roughEstimateOfLCPLoadStart
* @property {number} roughEstimateOfLCPLoadEnd
*/

/** @type {Array<string>} */
Expand Down Expand Up @@ -196,6 +202,10 @@ export default {
roughEstimateOfSI: evaluate('speedIndex', 'roughEstimateOfSI'),
roughEstimateOfTTI: evaluate('timeToConsistentlyInteractive', 'roughEstimateOfTTI'),
roughEstimateOfLCP: evaluate('largestContentfulPaint', 'roughEstimateOfLCP'),
// TODO: enable when new traces are collected.
// roughEstimateOfTTFB: evaluate('timeToFirstByte', 'roughEstimateOfTTFB'),
// roughEstimateOfLCPLoadStart: evaluate('largestContentfulPaintLoadStart', 'roughEstimateOfLCPLoadStart'),
// roughEstimateOfLCPLoadEnd: evaluate('largestContentfulPaintLoadEnd', 'roughEstimateOfLCPLoadEnd'),
};
},
};
9 changes: 7 additions & 2 deletions core/scripts/lantern/print-correlations.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function evaluateAndPrintAccuracy(metric, lanternMetric) {
const baselineOptions = {alwaysGray: !lanternMetric.includes('roughEstimate')};

const strings = [
lanternMetric.padEnd(25),
lanternMetric.padEnd(28),
`${toPercentString(actualAccuracy.p50)} ${toBaselineDiffString(
actualAccuracy.p50,
baselineAccuracy.p50,
Expand Down Expand Up @@ -216,7 +216,7 @@ function findAndPrintFixesRegressions() {

console.log(
chalk.bold(
'Metric'.padEnd(25),
'Metric'.padEnd(28),
'p50 (% Error)'.padEnd(20),
'p90 (% Error)'.padEnd(20),
'p95 (% Error)'.padEnd(20)
Expand All @@ -243,6 +243,11 @@ evaluateAndPrintAccuracy('largestContentfulPaint', 'optimisticLCP');
evaluateAndPrintAccuracy('largestContentfulPaint', 'pessimisticLCP');
evaluateAndPrintAccuracy('largestContentfulPaint', 'roughEstimateOfLCP');

// TODO: enable when new traces are collected (also, do calls to findAndPrintWorst10Sites)
// evaluateAndPrintAccuracy('timeToFirstByte', 'roughEstimateOfTTFB');
// evaluateAndPrintAccuracy('largestContentfulPaintLoadStart', 'roughEstimateOfLCPLoadStart');
// evaluateAndPrintAccuracy('largestContentfulPaintLoadEnd', 'roughEstimateOfLCPLoadEnd');

const estimates = allEvaluations.filter(entry => entry.lanternMetric.includes('roughEstimate'));
const baselineEstimates = baselineEvaluations.filter(entry =>
entry.lanternMetric.includes('roughEstimate')
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/lantern/update-baseline-lantern-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ fs.writeFileSync(OUTPUT_PATH, prettyJSONStringify({sites}, {
spaceBeforeColon: '',
spaceInsideObject: '',
shouldExpand: (_, level) => level < 2,
}));
}) + '\n');

fs.writeFileSync(OUTPUT_ACCURACY_PATH, JSON.stringify(
constants.evaluateAllMetrics(computedResults, {sites}),
null,
2
));
) + '\n');
Loading

0 comments on commit 49aa142

Please sign in to comment.