-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 desktop score curves for TBT and LCP #10756
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lighthouse-core/test/audits/metrics/largest-contentful-paint-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @license Copyright 2020 The Lighthouse Authors. 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 LCPAudit = require('../../../audits/metrics/largest-contentful-paint.js'); | ||
const defaultOptions = LCPAudit.defaultOptions; | ||
|
||
const trace = require('../../fixtures/traces/lcp-m78.json'); | ||
const devtoolsLog = require('../../fixtures/traces/lcp-m78.devtools.log.json'); | ||
|
||
function generateArtifacts({trace, devtoolsLog, TestedAsMobileDevice}) { | ||
return { | ||
traces: {[LCPAudit.DEFAULT_PASS]: trace}, | ||
devtoolsLogs: {[LCPAudit.DEFAULT_PASS]: devtoolsLog}, | ||
TestedAsMobileDevice, | ||
}; | ||
} | ||
|
||
function generateContext({throttlingMethod}) { | ||
const settings = {throttlingMethod}; | ||
return {options: defaultOptions, settings, computedCache: new Map()}; | ||
} | ||
/* eslint-env jest */ | ||
|
||
describe('Performance: largest-contentful-paint audit', () => { | ||
it('adjusts scoring based on form factor', async () => { | ||
const artifactsMobile = generateArtifacts({trace, devtoolsLog, TestedAsMobileDevice: true}); | ||
const contextMobile = generateContext({throttlingMethod: 'provided'}); | ||
|
||
const outputMobile = await LCPAudit.audit(artifactsMobile, contextMobile); | ||
expect(outputMobile.numericValue).toBeCloseTo(1121.711, 1); | ||
expect(outputMobile.score).toBe(1); | ||
expect(outputMobile.displayValue).toBeDisplayString('1.1\xa0s'); | ||
|
||
const artifactsDesktop = generateArtifacts({trace, devtoolsLog, TestedAsMobileDevice: false}); | ||
const contextDesktop = generateContext({throttlingMethod: 'provided'}); | ||
|
||
const outputDesktop = await LCPAudit.audit(artifactsDesktop, contextDesktop); | ||
expect(outputDesktop.numericValue).toBeCloseTo(1121.711, 1); | ||
expect(outputDesktop.score).toBe(0.92); | ||
expect(outputDesktop.displayValue).toBeDisplayString('1.1\xa0s'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this 13?
is this the x percentile of all web traffic or just desktop? (same question for mobile control points). comment doesn't make it clear, but the link to bigquery specifies mobile so I think it's filtering device type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#10715 changed the second control point from the PODR to p10, but in order to not change the curves, the p10 point ended up at a somewhat arbitrary percentile for each audit.
(this PR isn't changing any of the mobile numbers, though (?w=1 makes this a little clearer))
Right, the mobile and desktop data come from the percentiles in the respective http archive tables (
*_mobile
and*_desktop
) mentioned in each comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was decided to leave the LCP points as they were at some point prior and this is just a noop whitespace change.Commented at the same time as @brendankenny but he explained better :)