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(scoring): rebalance perf metric weightings #12577

Merged
merged 6 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,13 @@ Object {
"unminified-css",
"unused-css-rules",
],
"weight": 15,
"weight": 10,
},
Object {
"acronym": "SI",
"group": "metrics",
"id": "speed-index",
"weight": 15,
"weight": 10,
},
Object {
"acronym": "LCP",
Expand Down Expand Up @@ -889,7 +889,7 @@ Object {
"acronym": "TTI",
"group": "metrics",
"id": "interactive",
"weight": 15,
"weight": 10,
},
Object {
"acronym": "TBT",
Expand All @@ -905,7 +905,7 @@ Object {
"duplicated-javascript",
"legacy-javascript",
],
"weight": 25,
"weight": 30,
},
Object {
"acronym": "CLS",
Expand All @@ -916,7 +916,7 @@ Object {
"non-composited-animations",
"unsized-images",
],
"weight": 5,
"weight": 15,
},
Object {
"id": "max-potential-fid",
Expand Down
10 changes: 5 additions & 5 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ const defaultConfig = {
'performance': {
title: str_(UIStrings.performanceCategoryTitle),
auditRefs: [
{id: 'first-contentful-paint', weight: 15, group: 'metrics', acronym: 'FCP', relevantAudits: m2a.fcpRelevantAudits},
{id: 'speed-index', weight: 15, group: 'metrics', acronym: 'SI'},
{id: 'first-contentful-paint', weight: 10, group: 'metrics', acronym: 'FCP', relevantAudits: m2a.fcpRelevantAudits},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I totally missed this m2a business, sounds like someone has some apologizing to do to atob/btoa ;)

{id: 'speed-index', weight: 10, group: 'metrics', acronym: 'SI'},
{id: 'largest-contentful-paint', weight: 25, group: 'metrics', acronym: 'LCP', relevantAudits: m2a.lcpRelevantAudits},
{id: 'interactive', weight: 15, group: 'metrics', acronym: 'TTI'},
{id: 'total-blocking-time', weight: 25, group: 'metrics', acronym: 'TBT', relevantAudits: m2a.tbtRelevantAudits},
{id: 'cumulative-layout-shift', weight: 5, group: 'metrics', acronym: 'CLS', relevantAudits: m2a.clsRelevantAudits},
{id: 'interactive', weight: 10, group: 'metrics', acronym: 'TTI'},
{id: 'total-blocking-time', weight: 30, group: 'metrics', acronym: 'TBT', relevantAudits: m2a.tbtRelevantAudits},
{id: 'cumulative-layout-shift', weight: 15, group: 'metrics', acronym: 'CLS', relevantAudits: m2a.clsRelevantAudits},

// These are our "invisible" metrics. Not displayed, but still in the LHR
{id: 'max-potential-fid', weight: 0},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
* @return {string}
*/
_getScoringCalculatorHref(auditRefs) {
const v5andv6metrics = auditRefs.filter(audit => audit.group === 'metrics');
// TODO: filter by !!acronym when dropping renderer support of v7 LHRs.
const metrics = auditRefs.filter(audit => audit.group === 'metrics');
const fci = auditRefs.find(audit => audit.id === 'first-cpu-idle');
const fmp = auditRefs.find(audit => audit.id === 'first-meaningful-paint');
if (fci) v5andv6metrics.push(fci);
if (fmp) v5andv6metrics.push(fmp);
if (fci) metrics.push(fci);
if (fmp) metrics.push(fmp);

/**
* Clamp figure to 2 decimal places
Expand All @@ -125,7 +126,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
*/
const clampTo2Decimals = val => Math.round(val * 100) / 100;

const metricPairs = v5andv6metrics.map(audit => {
const metricPairs = metrics.map(audit => {
let value;
if (typeof audit.result.numericValue === 'number') {
value = audit.id === 'cumulative-layout-shift' ?
Expand Down
8 changes: 5 additions & 3 deletions lighthouse-core/test/report/report-generator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ describe('ReportGenerator', () => {
it('should inject the report templates', () => {
const page = new jsdom.JSDOM(ReportGenerator.generateReportHtml({}));
const templates = new jsdom.JSDOM(TEMPLATES_FILE);
assert.equal(page.window.document.querySelectorAll('template[id^="tmpl-"]').length,
assert.equal(
page.window.document.querySelectorAll('template[id^="tmpl-"]').length,
templates.window.document.querySelectorAll('template[id^="tmpl-"]').length,
'all templates injected');
'all templates injected'
);
});

it('should inject the report CSS', () => {
Expand Down Expand Up @@ -104,7 +106,7 @@ describe('ReportGenerator', () => {
expect(lines.length).toBeGreaterThan(100);
expect(lines.slice(0, 3).join('\n')).toMatchInlineSnapshot(`
"requestedUrl,finalUrl,category,name,title,type,score
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"performance-score\\",\\"Overall Performance Category Score\\",\\"numeric\\",\\"0.59\\"
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"performance-score\\",\\"Overall Performance Category Score\\",\\"numeric\\",\\"0.57\\"
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.24\\"
"
`);
Expand Down
12 changes: 6 additions & 6 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4954,7 +4954,7 @@
"auditRefs": [
{
"id": "first-contentful-paint",
"weight": 15,
"weight": 10,
"group": "metrics",
"acronym": "FCP",
"relevantAudits": [
Expand All @@ -4973,7 +4973,7 @@
},
{
"id": "speed-index",
"weight": 15,
"weight": 10,
"group": "metrics",
"acronym": "SI"
},
Expand Down Expand Up @@ -5003,13 +5003,13 @@
},
{
"id": "interactive",
"weight": 15,
"weight": 10,
"group": "metrics",
"acronym": "TTI"
},
{
"id": "total-blocking-time",
"weight": 25,
"weight": 30,
"group": "metrics",
"acronym": "TBT",
"relevantAudits": [
Expand All @@ -5025,7 +5025,7 @@
},
{
"id": "cumulative-layout-shift",
"weight": 5,
"weight": 15,
"group": "metrics",
"acronym": "CLS",
"relevantAudits": [
Expand Down Expand Up @@ -5276,7 +5276,7 @@
}
],
"id": "performance",
"score": 0.59
"score": 0.57
},
"accessibility": {
"title": "Accessibility",
Expand Down