Repository: GoogleChrome/lighthouse
Pull request #12577 (2021-05-28 00:23:29)

core(scoring): rebalance perf metric weightings
You can easily compare v8 with v6/7 scoring here: https://googlechrome.github.io/lighthouse/scorecalc/#FCP=3000&SI=5800&FMP=4000&TTI=7300&FCI=6500&LCP=4000&TBT=600&CLS=0.25&device=mobile&version=8&version=6&version=5

Readable summary and FAQ coming. 

For now, only internal draft at go/lh-perf-v8


Patch:
diff --git a/lighthouse-core/config/default-config.js b/lighthouse-core/config/default-config.js
index f268af85b..60c2522d8 100644
--- a/lighthouse-core/config/default-config.js
+++ b/lighthouse-core/config/default-config.js
@@ -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},
+        {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},
diff --git a/lighthouse-core/report/html/renderer/performance-category-renderer.js b/lighthouse-core/report/html/renderer/performance-category-renderer.js
index 51e6b6f8d..32997aede 100644
--- a/lighthouse-core/report/html/renderer/performance-category-renderer.js
+++ b/lighthouse-core/report/html/renderer/performance-category-renderer.js
@@ -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
@@ -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' ?


Test patch:
diff --git a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
index 742ee9996..209ccfc3c 100644
--- a/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
+++ b/lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
@@ -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",
@@ -889,7 +889,7 @@ Object {
           "acronym": "TTI",
           "group": "metrics",
           "id": "interactive",
-          "weight": 15,
+          "weight": 10,
         },
         Object {
           "acronym": "TBT",
@@ -905,7 +905,7 @@ Object {
             "duplicated-javascript",
             "legacy-javascript",
           ],
-          "weight": 25,
+          "weight": 30,
         },
         Object {
           "acronym": "CLS",
@@ -916,7 +916,7 @@ Object {
             "non-composited-animations",
             "unsized-images",
           ],
-          "weight": 5,
+          "weight": 15,
         },
         Object {
           "id": "max-potential-fid",
diff --git a/lighthouse-core/test/report/report-generator-test.js b/lighthouse-core/test/report/report-generator-test.js
index 98cdfc21d..b837fbe31 100644
--- a/lighthouse-core/test/report/report-generator-test.js
+++ b/lighthouse-core/test/report/report-generator-test.js
@@ -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', () => {
@@ -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\\"
         "
       `);
diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json
index 83e053ef1..8cf1f2560 100644
--- a/lighthouse-core/test/results/sample_v2.json
+++ b/lighthouse-core/test/results/sample_v2.json
@@ -4954,7 +4954,7 @@
       "auditRefs": [
         {
           "id": "first-contentful-paint",
-          "weight": 15,
+          "weight": 10,
           "group": "metrics",
           "acronym": "FCP",
           "relevantAudits": [
@@ -4973,7 +4973,7 @@
         },
         {
           "id": "speed-index",
-          "weight": 15,
+          "weight": 10,
           "group": "metrics",
           "acronym": "SI"
         },
@@ -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": [
@@ -5025,7 +5025,7 @@
         },
         {
           "id": "cumulative-layout-shift",
-          "weight": 5,
+          "weight": 15,
           "group": "metrics",
           "acronym": "CLS",
           "relevantAudits": [
@@ -5276,7 +5276,7 @@
         }
       ],
       "id": "performance",
-      "score": 0.59
+      "score": 0.57
     },
     "accessibility": {
       "title": "Accessibility",