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

core: add largest contentful paint to lantern and default config #9905

Merged
merged 50 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ec75de3
first pass
connorjclark Sep 20, 2019
183b080
update
connorjclark Sep 20, 2019
03f8ab6
i18n
connorjclark Sep 20, 2019
52a8d28
typos
connorjclark Sep 20, 2019
4e2e688
metrics
connorjclark Sep 20, 2019
f1836a0
ts
connorjclark Sep 20, 2019
449c7c5
fix
connorjclark Sep 20, 2019
d821da7
Apply suggestions from code review
connorjclark Sep 20, 2019
9cc6b8c
todo
connorjclark Sep 20, 2019
211a90b
fix lcp
connorjclark Sep 20, 2019
ee9f34e
update sample trace
connorjclark Sep 20, 2019
24db2ed
tweaks
connorjclark Sep 20, 2019
308f0fe
fix metrics-test
connorjclark Sep 20, 2019
33fecc9
rename all those pwa trace requires
connorjclark Sep 20, 2019
2b87da0
just update all the metric snapshots
connorjclark Sep 20, 2019
c473bf5
undo tests
connorjclark Sep 23, 2019
26bb02a
m79 in metrics test
connorjclark Sep 23, 2019
b848a73
m60
connorjclark Sep 23, 2019
967d630
lcp metric trace test
connorjclark Sep 24, 2019
5b80688
Merge remote-tracking branch 'origin/master' into lcp
connorjclark Sep 27, 2019
9da66f9
pr
connorjclark Sep 27, 2019
49aa30a
Update lighthouse-core/lib/tracehouse/trace-processor.js
connorjclark Sep 27, 2019
a71ab04
Merge branch 'lcp' of github.com:GoogleChrome/lighthouse into lcp
connorjclark Sep 27, 2019
7fd52f4
Apply suggestions from code review
connorjclark Sep 30, 2019
f351590
update traces
connorjclark Oct 1, 2019
ff42528
minify trace
connorjclark Oct 1, 2019
e93e396
first pass
connorjclark Oct 15, 2019
9103431
wip
connorjclark Oct 15, 2019
a3fade6
fix print
connorjclark Oct 29, 2019
567efc2
improve
connorjclark Oct 29, 2019
459a1de
Merge remote-tracking branch 'origin/master' into lcp-lantern
connorjclark Oct 30, 2019
a0b31db
lint, update with master
connorjclark Oct 30, 2019
045b829
add lcp to default config
connorjclark Oct 30, 2019
498df14
fix tests
connorjclark Oct 30, 2019
7bb9d86
rm stuff
connorjclark Oct 30, 2019
de48435
Merge remote-tracking branch 'origin/master' into lcp-lantern
connorjclark Nov 8, 2019
eb3599e
pr
connorjclark Nov 8, 2019
6d12f11
Apply suggestions from code review
connorjclark Nov 9, 2019
fa7f089
lint. line length
paulirish Nov 9, 2019
42b7ad1
fix lantern test
connorjclark Nov 9, 2019
8b5cce0
Merge remote-tracking branch 'origin/master' into lcp-lantern
connorjclark Nov 9, 2019
ce0042b
fix tests
connorjclark Nov 9, 2019
bbc5030
fix trace processor test
connorjclark Nov 9, 2019
9812701
rm common prefix
connorjclark Nov 9, 2019
e0a04b7
fix cli test
connorjclark Nov 9, 2019
2d34e65
delete old test
connorjclark Nov 9, 2019
6a1fdb7
pr
connorjclark Nov 9, 2019
1579ccb
comment
connorjclark Nov 9, 2019
5fc5db0
Merge remote-tracking branch 'origin/master' into lcp-lantern
connorjclark Nov 10, 2019
98f3ea2
use a better trace for lcp
connorjclark Nov 10, 2019
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
71 changes: 71 additions & 0 deletions lighthouse-core/audits/metrics/largest-contentful-paint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const Audit = require('../audit.js');
const i18n = require('../../lib/i18n/i18n.js');
const ComputedLcp = require('../../computed/metrics/largest-contentful-paint.js');

const UIStrings = {
/** The name of the metric that marks the time at which the largest text or image is painted by the browser. Shown to users as the label for the numeric metric value. Ideally fits within a ~40 character limit. */
title: 'Largest Contentful Paint',
/** Description of the Largest Contentful Paint (LCP) metric, which marks the time at which the largest text or image is painted by the browser. This is displayed within a tooltip when the user hovers on the metric name to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
description: 'Largest Contentful Paint marks the time at which the largest text or image is ' +
`painted. [Learn More](https://web.dev/largest-contentful-paint)`, // TODO: waiting on LH specific doc.
};

const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);

class LargestContentfulPaint extends Audit {
/**
* @return {LH.Audit.Meta}
*/
static get meta() {
return {
id: 'largest-contentful-paint',
title: str_(UIStrings.title),
description: str_(UIStrings.description),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces', 'devtoolsLogs'],
};
}

/**
* @return {LH.Audit.ScoreOptions}
*/
static get defaultOptions() {
return {
// TODO: Reusing FCP's scoring curve. Set correctly once distribution of results is available.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brendankenny is it your estimation that we won't have any data on this? can we get access to the november run that hopefully has our good chrome?

scorePODR: 2000,
scoreMedian: 4000,
};
}

/**
* @param {LH.Artifacts} artifacts
* @param {LH.Audit.Context} context
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
const metricComputationData = {trace, devtoolsLog, settings: context.settings};
const metricResult = await ComputedLcp.request(metricComputationData, context);

return {
score: Audit.computeLogNormalScore(
metricResult.timing,
context.options.scorePODR,
context.options.scoreMedian
),
numericValue: metricResult.timing,
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}),
};
}
}

module.exports = LargestContentfulPaint;
module.exports.UIStrings = UIStrings;
6 changes: 6 additions & 0 deletions lighthouse-core/audits/predictive-perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const LanternInteractive = require('../computed/metrics/lantern-interactive.js')
const LanternFirstCPUIdle = require('../computed/metrics/lantern-first-cpu-idle.js');
const LanternSpeedIndex = require('../computed/metrics/lantern-speed-index.js');
const LanternEil = require('../computed/metrics/lantern-estimated-input-latency.js');
const LanternLcp = require('../computed/metrics/lantern-largest-contentful-paint.js');

// Parameters (in ms) for log-normal CDF scoring. To see the curve:
// https://www.desmos.com/calculator/rjp0lbit8y
Expand Down Expand Up @@ -53,6 +54,7 @@ class PredictivePerf extends Audit {
const ttfcpui = await LanternFirstCPUIdle.request({trace, devtoolsLog, settings}, context);
const si = await LanternSpeedIndex.request({trace, devtoolsLog, settings}, context);
const eil = await LanternEil.request({trace, devtoolsLog, settings}, context);
const lcp = await LanternLcp.request({trace, devtoolsLog, settings}, context);

const values = {
roughEstimateOfFCP: fcp.timing,
Expand All @@ -78,6 +80,10 @@ class PredictivePerf extends Audit {
roughEstimateOfEIL: eil.timing,
optimisticEIL: eil.optimisticEstimate.timeInMs,
pessimisticEIL: eil.pessimisticEstimate.timeInMs,

roughEstimateOfLCP: lcp.timing,
optimisticLCP: lcp.optimisticEstimate.timeInMs,
pessimisticLCP: lcp.pessimisticEstimate.timeInMs,
};

const score = Audit.computeLogNormalScore(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const makeComputedArtifact = require('../computed-artifact.js');
const LanternMetric = require('./lantern-metric.js');
const LHError = require('../../lib/lh-error.js');
const LanternFirstContentfulPaint = require('./lantern-first-contentful-paint.js');

/** @typedef {import('../../lib/dependency-graph/base-node.js').Node} Node */

class LanternLargestContentfulPaint extends LanternMetric {
/**
* @return {LH.Gatherer.Simulation.MetricCoefficients}
*/
static get COEFFICIENTS() {
return {
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
intercept: 0,
optimistic: 0.5,
pessimistic: 0.5,
};
}

/**
* TODO: Validate.
* @param {Node} dependencyGraph
* @param {LH.Artifacts.TraceOfTab} traceOfTab
* @return {Node}
*/
static getOptimisticGraph(dependencyGraph, traceOfTab) {
const lcp = traceOfTab.timestamps.largestContentfulPaint;
if (!lcp) {
throw new LHError(LHError.errors.NO_LCP);
}

return LanternFirstContentfulPaint.getFirstPaintBasedGraph(
dependencyGraph,
lcp,
_ => true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still working on this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't made any progress on improving this. @patrickhulce any ideas? Or maybe the accuracy is good enough (would want to use the new data you're collecting from GCP before saying for sure).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's wait for the full dataset before we invest too much more time.

@connorjclark I'll need to ping you separately for a more privileged key to run the actual collection since mine is capped at 200/day

https://github.com/GoogleChrome/lighthouse/tree/patrick_collect_gcp/lighthouse-core/scripts/lantern/collect

if you want to peek though :)

);
}

/**
* TODO: Validate.
* @param {Node} dependencyGraph
* @param {LH.Artifacts.TraceOfTab} traceOfTab
* @return {Node}
*/
static getPessimisticGraph(dependencyGraph, traceOfTab) {
const lcp = traceOfTab.timestamps.largestContentfulPaint;
if (!lcp) {
throw new LHError(LHError.errors.NO_LCP);
}

return LanternFirstContentfulPaint.getFirstPaintBasedGraph(
dependencyGraph,
lcp,
_ => true,
// For pessimistic LCP we'll include *all* layout nodes
node => node.didPerformLayout()
);
}

/**
* @param {LH.Artifacts.MetricComputationDataInput} data
* @param {LH.Audit.Context} context
* @return {Promise<LH.Artifacts.LanternMetric>}
*/
static async compute_(data, context) {
const fcpResult = await LanternFirstContentfulPaint.request(data, context);
const metricResult = await this.computeMetricWithGraphs(data, context);
metricResult.timing = Math.max(metricResult.timing, fcpResult.timing);
return metricResult;
}
}

module.exports = makeComputedArtifact(LanternLargestContentfulPaint);
13 changes: 7 additions & 6 deletions lighthouse-core/computed/metrics/largest-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
*/
'use strict';

const makeComputedArtifact = require('../computed-artifact.js');
const ComputedMetric = require('./metric.js');
const LHError = require('../../lib/lh-error.js');

/**
* @fileoverview Computed Largest Contentful Paint (LCP), the paint time of the largest in-viewport contentful element
* COMPAT: LCP's trace event was first introduced in m78. We can't surface an LCP for older Chrome versions
* @see https://github.com/WICG/largest-contentful-paint
* @see https://wicg.github.io/largest-contentful-paint/
* @see https://web.dev/largest-contentful-paint
*/

const makeComputedArtifact = require('../computed-artifact.js');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, any reason for moving these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a file overview comment block should be the first thing in a file (except license / strict i guess)

do you hate it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're inconsistent about this already. it looks 50/50 in a brief survey.

being inconsistent would suggest that we leave existing ones as they lie until we fix all of them at once. (i think that's what we've done before in similar situations... require('xx.js').. right?)

that said i dont think its important this time. so lets ignore this one.. just this one time. :)

const ComputedMetric = require('./metric.js');
const LHError = require('../../lib/lh-error.js');
const LanternLargestContentfulPaint = require('./lantern-largest-contentful-paint.js');

class LargestContentfulPaint extends ComputedMetric {
/**
* @param {LH.Artifacts.MetricComputationData} data
* @param {LH.Audit.Context} context
* @return {Promise<LH.Artifacts.LanternMetric>}
*/
// eslint-disable-next-line no-unused-vars
static computeSimulatedMetric(data, context) {
throw new Error('Unimplemented');
return LanternLargestContentfulPaint.request(data, context);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const defaultConfig = {
'without-javascript',
'metrics/first-contentful-paint',
'metrics/first-meaningful-paint',
'metrics/largest-contentful-paint',
'load-fast-enough-for-pwa',
'metrics/speed-index',
'screenshot-thumbnails',
Expand Down Expand Up @@ -383,6 +384,7 @@ const defaultConfig = {
auditRefs: [
{id: 'first-contentful-paint', weight: 3, group: 'metrics'},
{id: 'first-meaningful-paint', weight: 1, group: 'metrics'},
{id: 'largest-contentful-paint', weight: 0, group: 'metrics'},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulirish do I recall correctly that we intend to give this one of the highest weights right out of the gate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. i'll do that in a followup PR. :)

{id: 'speed-index', weight: 4, group: 'metrics'},
{id: 'interactive', weight: 5, group: 'metrics'},
{id: 'first-cpu-idle', weight: 2, group: 'metrics'},
Expand Down
6 changes: 6 additions & 0 deletions lighthouse-core/lib/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@
"lighthouse-core/audits/metrics/interactive.js | description": {
"message": "Time to interactive is the amount of time it takes for the page to become fully interactive. [Learn more](https://web.dev/interactive)."
},
"lighthouse-core/audits/metrics/largest-contentful-paint.js | description": {
"message": "Largest Contentful Paint marks the time at which the largest text or image is painted. [Learn More](https://web.dev/largest-contentful-paint)"
},
"lighthouse-core/audits/metrics/largest-contentful-paint.js | title": {
"message": "Largest Contentful Paint"
},
"lighthouse-core/audits/metrics/max-potential-fid.js | description": {
"message": "The maximum potential First Input Delay that your users could experience is the duration, in milliseconds, of the longest task. [Learn more](https://web.dev/lighthouse-max-potential-fid)."
},
Expand Down
6 changes: 6 additions & 0 deletions lighthouse-core/lib/i18n/locales/en-XL.json
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@
"lighthouse-core/audits/metrics/interactive.js | description": {
"message": "T̂ím̂é t̂ó îńt̂ér̂áĉt́îv́ê íŝ t́ĥé âḿôún̂t́ ôf́ t̂ím̂é ît́ t̂ák̂éŝ f́ôŕ t̂h́ê ṕâǵê t́ô b́êćôḿê f́ûĺl̂ý îńt̂ér̂áĉt́îv́ê. [Ĺêár̂ń m̂ór̂é](https://web.dev/interactive)."
},
"lighthouse-core/audits/metrics/largest-contentful-paint.js | description": {
"message": "L̂ár̂ǵêśt̂ Ćôńt̂én̂t́f̂úl̂ Ṕâín̂t́ m̂ár̂ḱŝ t́ĥé t̂ím̂é ât́ ŵh́îćĥ t́ĥé l̂ár̂ǵêśt̂ t́êx́t̂ ór̂ ím̂áĝé îś p̂áîńt̂éd̂. [Ĺêár̂ń M̂ór̂é](https://web.dev/largest-contentful-paint)"
},
"lighthouse-core/audits/metrics/largest-contentful-paint.js | title": {
"message": "L̂ár̂ǵêśt̂ Ćôńt̂én̂t́f̂úl̂ Ṕâín̂t́"
},
"lighthouse-core/audits/metrics/max-potential-fid.js | description": {
"message": "T̂h́ê ḿâx́îḿûḿ p̂ót̂én̂t́îál̂ F́îŕŝt́ Îńp̂út̂ D́êĺâý t̂h́ât́ ŷóûŕ ûśêŕŝ ćôúl̂d́ êx́p̂ér̂íêńĉé îś t̂h́ê d́ûŕât́îón̂, ín̂ ḿîĺl̂íŝéĉón̂d́ŝ, óf̂ t́ĥé l̂ón̂ǵêśt̂ t́âśk̂. [Ĺêár̂ń m̂ór̂é](https://web.dev/lighthouse-max-potential-fid)."
},
Expand Down
13 changes: 13 additions & 0 deletions lighthouse-core/scripts/lantern/print-correlations.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @property {number} [timeToFirstInteractive]
* @property {number} [timeToConsistentlyInteractive]
* @property {number} [speedIndex]
* @property {number} [largestContentfulPaint]
*/

/**
Expand All @@ -51,16 +52,19 @@
* @property {number} optimisticSI
* @property {number} optimisticTTFCPUI
* @property {number} optimisticTTI
* @property {number} optimisticLCP
* @property {number} pessimisticFCP
* @property {number} pessimisticFMP
* @property {number} pessimisticSI
* @property {number} pessimisticTTFCPUI
* @property {number} pessimisticTTI
* @property {number} pessimisticLCP
* @property {number} roughEstimateOfFCP
* @property {number} roughEstimateOfFMP
* @property {number} roughEstimateOfSI
* @property {number} roughEstimateOfTTFCPUI
* @property {number} roughEstimateOfTTI
* @property {number} roughEstimateOfLCP
*/

const fs = require('fs');
Expand Down Expand Up @@ -351,6 +355,10 @@ evaluateAndPrintAccuracy('speedIndex', 'optimisticSI');
evaluateAndPrintAccuracy('speedIndex', 'pessimisticSI');
evaluateAndPrintAccuracy('speedIndex', 'roughEstimateOfSI');

evaluateAndPrintAccuracy('largestContentfulPaint', 'optimisticLCP');
evaluateAndPrintAccuracy('largestContentfulPaint', 'pessimisticLCP');
evaluateAndPrintAccuracy('largestContentfulPaint', 'roughEstimateOfLCP');

const estimates = allEvaluations.filter(entry => entry.lanternMetric.includes('roughEstimate'));
const baselineEstimates = baselineEvaluations.filter(entry =>
entry.lanternMetric.includes('roughEstimate')
Expand All @@ -377,6 +385,11 @@ findAndPrintWorst10Sites('timeToConsistentlyInteractive', [
'roughEstimateOfTTI',
]);
findAndPrintWorst10Sites('speedIndex', ['optimisticSI', 'pessimisticSI', 'roughEstimateOfSI']);
findAndPrintWorst10Sites('largestContentfulPaint', [
'optimisticLCP',
'pessimisticLCP',
'roughEstimateOfLCP',
]);

findAndPrintFixesRegressions();

Expand Down
17 changes: 10 additions & 7 deletions lighthouse-core/scripts/lantern/run-on-all-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ for (const site of expectations.sites) {
const log = path.join(SITE_INDEX_DIR, site.unthrottled.devtoolsLogPath);

console.log('Running', site.url, '...');
const rawOutput = execFileSync(RUN_ONCE_PATH, [trace, log])
.toString()
.trim();
if (!rawOutput) console.log('ERROR EMPTY OUTPUT!');
const lantern = JSON.parse(rawOutput);

Object.assign(site, {lantern});
try {
const rawOutput = execFileSync(RUN_ONCE_PATH, [trace, log])
.toString()
.trim();
if (!rawOutput) console.log('ERROR EMPTY OUTPUT!');
const lantern = JSON.parse(rawOutput);
Object.assign(site, {lantern});
} catch (e) {
console.error(e);
}
}

// eslint-disable-next-line max-len
Expand Down
42 changes: 42 additions & 0 deletions lighthouse-core/test/audits/__snapshots__/metrics-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,48 @@ Object {
}
`;

exports[`Performance: metrics evaluates valid input (with lcp) correctly 2`] = `
Object {
"estimatedInputLatency": 1324,
"estimatedInputLatencyTs": undefined,
"firstCPUIdle": 14907,
"firstCPUIdleTs": 1671236823075,
"firstContentfulPaint": 4702,
"firstContentfulPaintTs": 1671226617803,
"firstMeaningfulPaint": 4702,
"firstMeaningfulPaintTs": 1671226617803,
"interactive": 14907,
"interactiveTs": 1671236823075,
"largestContentfulPaint": 15024,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely concerning that it's after TTI, that seems like it should not be possible...

maybe we should be doing some math.max/math.min to make things make sense like we do for the other paint metrics?

Copy link
Collaborator Author

@connorjclark connorjclark Nov 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would it not be possible? an image can take a while to load, and if the LCP element is an element, that delay is relevant (not claiming that is whats happening here). LCP has nothing to do with main thread in that case

"largestContentfulPaintTs": 1671236939268,
"observedDomContentLoaded": 14907,
"observedDomContentLoadedTs": 1671236823075,
"observedFirstContentfulPaint": 4702,
"observedFirstContentfulPaintTs": 1671226617803,
"observedFirstMeaningfulPaint": 4702,
"observedFirstMeaningfulPaintTs": 1671226617803,
"observedFirstPaint": 4702,
"observedFirstPaintTs": 1671226617803,
"observedFirstVisualChange": 4685,
"observedFirstVisualChangeTs": 1671226600754,
"observedLargestContentfulPaint": 15024,
"observedLargestContentfulPaintTs": 1671236939268,
"observedLastVisualChange": 4685,
"observedLastVisualChangeTs": 1671226600754,
"observedLoad": 40464,
"observedLoadTs": 1671262379989,
"observedNavigationStart": 0,
"observedNavigationStartTs": 1671221915754,
"observedSpeedIndex": 5715,
"observedSpeedIndexTs": 1671227631023,
"observedTraceEnd": 44549,
"observedTraceEndTs": 1671266464483,
"speedIndex": 5715,
"speedIndexTs": 1671227630754,
"totalBlockingTime": 1935,
}
`;

exports[`Performance: metrics evaluates valid input correctly 1`] = `
Object {
"estimatedInputLatency": 78,
Expand Down
15 changes: 15 additions & 0 deletions lighthouse-core/test/audits/metrics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,19 @@ describe('Performance: metrics', () => {
const result = await MetricsAudit.audit(artifacts, context);
expect(result.details.items[0].interactive).toEqual(undefined);
});

it('evaluates valid input (with lcp) correctly', async () => {
const artifacts = {
traces: {
[MetricsAudit.DEFAULT_PASS]: lcpTrace,
},
devtoolsLogs: {
[MetricsAudit.DEFAULT_PASS]: lcpDevtoolsLog,
},
};

const context = {settings: {throttlingMethod: 'devtools'}, computedCache: new Map()};
const result = await MetricsAudit.audit(artifacts, context);
expect(result.details.items[0]).toMatchSnapshot();
});
});
Loading