-
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 all commits
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.js'); | ||
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 | ||
// 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ const config = { | |
throughputKbps: 10 * 1024, | ||
cpuSlowdownMultiplier: 1, | ||
}, | ||
// Skip the h2 audit so it doesn't lie to us. See #6539 | ||
// Skip the h2 audit so it doesn't lie to us. See https://github.com/GoogleChrome/lighthouse/issues/6539 | ||
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. ❤️ |
||
skipAudits: ['uses-http2'], | ||
}, | ||
audits: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* @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 FCP3G = require('../../../audits/metrics/first-contentful-paint-3g.js'); | ||
const options = FCP3G.defaultOptions; | ||
|
||
const pwaTrace = require('../../fixtures/traces/progressive-app-m60.json'); | ||
const pwaDevtoolsLog = require('../../fixtures/traces/progressive-app-m60.devtools.log.json'); | ||
|
||
/* eslint-env jest */ | ||
|
||
describe('Performance: first-contentful-paint-3g audit', () => { | ||
it('evaluates valid input correctly', async () => { | ||
const artifacts = { | ||
traces: { | ||
[FCP3G.DEFAULT_PASS]: pwaTrace, | ||
}, | ||
devtoolsLogs: { | ||
[FCP3G.DEFAULT_PASS]: pwaDevtoolsLog, | ||
}, | ||
}; | ||
|
||
const result = await FCP3G.audit(artifacts, {settings: {}, options, computedCache: new Map()}); | ||
// Use InlineSnapshot here so changes to Lantern coefficients can be easily updated en masse | ||
expect({score: result.score, value: Math.round(result.rawValue)}).toMatchInlineSnapshot(` | ||
Object { | ||
"score": 1, | ||
"value": 1661, | ||
} | ||
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. lol |
||
`); | ||
}); | ||
}); |
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.
multiply what by 1.5?
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.
the 75th and 95th percentiles :)
the
->
is meant to be like a pipe