-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 FCP on 3G audit to JSON #7062
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @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'); | ||
const regular3G = require('../../config/constants.js').throttling.mobileRegluar3G; | ||
const i18n = require('../../lib/i18n/i18n.js'); | ||
const FCP = require('./first-contentful-paint.js'); | ||
const ComputedFcp = require('../../computed/metrics/first-contentful-paint.js'); | ||
|
||
const i18nFilename = require.resolve('./first-contentful-paint.js'); | ||
const str_ = i18n.createMessageInstanceIdFn(i18nFilename, FCP.UIStrings); | ||
|
||
class FirstContentfulPaint3G extends Audit { | ||
/** | ||
* @return {LH.Audit.Meta} | ||
*/ | ||
static get meta() { | ||
return { | ||
id: 'first-contentful-paint-3g', | ||
title: str_(FCP.UIStrings.title), | ||
description: str_(FCP.UIStrings.description), | ||
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC, | ||
requiredArtifacts: ['traces', 'devtoolsLogs'], | ||
}; | ||
} | ||
|
||
/** | ||
* @return {LH.Audit.ScoreOptions} | ||
*/ | ||
static get defaultOptions() { | ||
return { | ||
// 75th and 95th percentiles HTTPArchive on Fast 3G -> multiply by 1.5 for RTT differential -> median and PODR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multiply what by 1.5? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the 75th and 95th percentiles :) the |
||
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1 | ||
scorePODR: 3000, | ||
scoreMedian: 6000, | ||
}; | ||
} | ||
|
||
/** | ||
* @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]; | ||
/** @type {LH.Config.Settings} */ | ||
const settings = {...context.settings, throttlingMethod: 'simulate', throttling: regular3G}; | ||
const metricComputationData = {trace, devtoolsLog, settings}; | ||
const metricResult = await ComputedFcp.request(metricComputationData, context); | ||
|
||
return { | ||
score: Audit.computeLogNormalScore( | ||
metricResult.timing, | ||
context.options.scorePODR, | ||
context.options.scoreMedian | ||
), | ||
rawValue: metricResult.timing, | ||
displayValue: str_(i18n.UIStrings.seconds, {timeInMs: metricResult.timing}), | ||
}; | ||
} | ||
} | ||
|
||
module.exports = FirstContentfulPaint3G; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,7 @@ const defaultConfig = { | |
'without-javascript', | ||
'metrics/first-contentful-paint', | ||
'metrics/first-meaningful-paint', | ||
'metrics/first-contentful-paint-3g', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we add this to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah good call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we only need it in mobile right @paulirish ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this change only applied to mobile? I was testing with this version and all the desktop scores went down dramatically for first contentful paint. Are we sure that this metrics is not accidentally included in the desktop fcp score calculation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you're comparing to PSI you need to use the same settings PSI uses. If you have the repo/code locally, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh thank you. This is invaluable information. Does that mean that in version v3.2.1 the configuration There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @patrickhulce seems this issue has put the internet in a frenzy. There are several threads in the PSI group. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dgargi @patrickhulce thanks so much for the quick investigation. I filed #7151 and if you need more information, let me know. Thanks! |
||
'load-fast-enough-for-pwa', | ||
'metrics/speed-index', | ||
'screenshot-thumbnails', | ||
|
@@ -349,6 +350,7 @@ const defaultConfig = { | |
{id: 'dom-size', weight: 0, group: 'diagnostics'}, | ||
{id: 'critical-request-chains', weight: 0, group: 'diagnostics'}, | ||
{id: 'network-requests', weight: 0}, | ||
{id: 'first-contentful-paint-3g', weight: 0}, | ||
{id: 'metrics', weight: 0}, | ||
{id: 'user-timings', weight: 0, group: 'diagnostics'}, | ||
{id: 'bootup-time', weight: 0, group: 'diagnostics'}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,15 @@ | |
"rawValue": 3969.136, | ||
"displayValue": "4.0 s" | ||
}, | ||
"first-contentful-paint-3g": { | ||
"id": "first-contentful-paint-3g", | ||
"title": "First Contentful Paint", | ||
"description": "First Contentful Paint marks the time at which the first text or image is painted. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/first-contentful-paint).", | ||
"score": 0.22, | ||
"scoreDisplayMode": "numeric", | ||
"rawValue": 8321.9015, | ||
"displayValue": "8.3 s" | ||
}, | ||
"load-fast-enough-for-pwa": { | ||
"id": "load-fast-enough-for-pwa", | ||
"title": "Page load is fast enough on mobile networks", | ||
|
@@ -2928,6 +2937,10 @@ | |
"id": "network-requests", | ||
"weight": 0 | ||
}, | ||
{ | ||
"id": "first-contentful-paint-3g", | ||
"weight": 0 | ||
}, | ||
{ | ||
"id": "metrics", | ||
"weight": 0 | ||
|
@@ -3582,6 +3595,42 @@ | |
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:audit:first-contentful-paint-3g", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:FirstContentfulPaint", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these duplicate keys are kind of a bummer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it is :( I'm not sure it's worth sticking the options into the name though to differentiate either though :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yeah, will probably just confuse things without much benefit. If someone cares about that they'll be more likely to be looking at things in the timeline viewer anyways |
||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:LanternFirstContentfulPaint", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:PageDependencyGraph", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:LoadSimulator", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:NetworkAnalysis", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:audit:load-fast-enough-for-pwa", | ||
|
@@ -3726,24 +3775,12 @@ | |
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:PageDependencyGraph", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:LoadSimulator", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:computed:NetworkAnalysis", | ||
"duration": 100, | ||
"entryType": "measure" | ||
}, | ||
{ | ||
"startTime": 0, | ||
"name": "lh:audit:installable-manifest", | ||
|
@@ -4393,10 +4430,12 @@ | |
}, | ||
"icuMessagePaths": { | ||
"lighthouse-core/audits/metrics/first-contentful-paint.js | title": [ | ||
"audits[first-contentful-paint].title" | ||
"audits[first-contentful-paint].title", | ||
"audits[first-contentful-paint-3g].title" | ||
], | ||
"lighthouse-core/audits/metrics/first-contentful-paint.js | description": [ | ||
"audits[first-contentful-paint].description" | ||
"audits[first-contentful-paint].description", | ||
"audits[first-contentful-paint-3g].description" | ||
], | ||
"lighthouse-core/lib/i18n/i18n.js | seconds": [ | ||
{ | ||
|
@@ -4411,6 +4450,12 @@ | |
}, | ||
"path": "audits[first-meaningful-paint].displayValue" | ||
}, | ||
{ | ||
"values": { | ||
"timeInMs": 8321.9015 | ||
}, | ||
"path": "audits[first-contentful-paint-3g].displayValue" | ||
}, | ||
{ | ||
"values": { | ||
"timeInMs": 4417 | ||
|
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.
audit.js
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.
done