diff --git a/core/audits/server-response-time.js b/core/audits/server-response-time.js index c0df87c657c1..a80dde34fa51 100644 --- a/core/audits/server-response-time.js +++ b/core/audits/server-response-time.js @@ -70,11 +70,16 @@ class ServerResponseTime extends Audit { {key: 'responseTime', valueType: 'timespanMs', label: str_(i18n.UIStrings.columnTimeSpent)}, ]; + const overallSavingsMs = Math.max(responseTime - TARGET_MS, 0); const details = Audit.makeOpportunityDetails( headings, [{url: mainResource.url, responseTime}], - {overallSavingsMs: responseTime - TARGET_MS} + {overallSavingsMs} ); + details.metricSavings = { + FCP: overallSavingsMs, + LCP: overallSavingsMs, + }; return { numericValue: responseTime, diff --git a/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json b/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json index 4d5ce46cdf97..098dd6b5ca9f 100644 --- a/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json +++ b/core/test/fixtures/fraggle-rock/reports/sample-flow-result.json @@ -233,7 +233,11 @@ "responseTime": 19.687999999999988 } ], - "overallSavingsMs": -80.31200000000001 + "overallSavingsMs": 0, + "metricSavings": { + "FCP": 0, + "LCP": 0 + } } }, "interactive": { @@ -16685,7 +16689,11 @@ "responseTime": 10.263 } ], - "overallSavingsMs": -89.737 + "overallSavingsMs": 0, + "metricSavings": { + "FCP": 0, + "LCP": 0 + } } }, "interactive": { diff --git a/core/test/results/sample_v2.json b/core/test/results/sample_v2.json index 4cc4e127b822..8bcae53c9ede 100644 --- a/core/test/results/sample_v2.json +++ b/core/test/results/sample_v2.json @@ -336,7 +336,11 @@ "responseTime": 568.468 } ], - "overallSavingsMs": 468.46799999999996 + "overallSavingsMs": 468.46799999999996, + "metricSavings": { + "FCP": 468.46799999999996, + "LCP": 468.46799999999996 + } } }, "interactive": { diff --git a/types/lhr/audit-details.d.ts b/types/lhr/audit-details.d.ts index 17611dcf9baf..fc054c6913cf 100644 --- a/types/lhr/audit-details.d.ts +++ b/types/lhr/audit-details.d.ts @@ -15,6 +15,8 @@ interface BaseDetails { overallSavingsBytes?: number; /** Additional information, usually used for including debug or meta information in the LHR */ debugData?: Details.DebugData; + /** Estimates of how much this audit affects various performance metrics. Values will be in the unit of the respective metrics. */ + metricSavings?: Details.MetricSavings; } type Details = @@ -303,6 +305,14 @@ declare module Details { value: number, granularity?: number, } + + interface MetricSavings { + LCP?: number; + FCP?: number; + CLS?: number; + TBT?: number; + INP?: number; + } } export default Details; diff --git a/types/lhr/audit-result.d.ts b/types/lhr/audit-result.d.ts index b8285eca4bd9..48b3146740e4 100644 --- a/types/lhr/audit-result.d.ts +++ b/types/lhr/audit-result.d.ts @@ -50,6 +50,8 @@ export interface Result { id: string; /** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */ description: string; + /** Estimates of how much this audit affects various performance metrics. Values will be in the unit of the respective metrics. */ + metricSavings?: AuditDetails.MetricSavings; /** A numeric value that has a meaning specific to the audit, e.g. the number of nodes in the DOM or the timestamp of a specific load event. More information can be found in the audit details, if present. */ numericValue?: number; /** The unit of `numericValue`, used when the consumer wishes to convert numericValue to a display string. */