Skip to content

Commit 9de0b5d

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Add estimated savings to insight formatter for agent
Bug: 425268387 Change-Id: I96dd6c2d480d0442689d9f3f39fd015d8e01c3e8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6789009 Reviewed-by: Paul Irish <[email protected]> Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent c40b214 commit 9de0b5d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ We can break this time down into the 4 phases that combine to make the LCP time:
5858
- Resource load duration: 14.70 ms (11.4% of total LCP time)
5959
- Element render delay: 73.41 ms (56.8% of total LCP time)
6060
61+
## Estimated savings: none
62+
6163
## External resources:
6264
- https://web.dev/articles/lcp
6365
- https://web.dev/articles/optimize-lcp`;
@@ -86,6 +88,8 @@ We can break this time down into the 2 phases that combine to make the LCP time:
8688
- Time to first byte: 6.12 ms (5.7% of total LCP time)
8789
- Element render delay: 100.37 ms (94.3% of total LCP time)
8890
91+
## Estimated savings: none
92+
8993
## External resources:
9094
- https://web.dev/articles/lcp
9195
- https://web.dev/articles/optimize-lcp`;
@@ -131,6 +135,8 @@ This insight identifies network requests that were render blocking. Render block
131135
## Detailed analysis:
132136
There are no network requests that are render blocking.
133137
138+
## Estimated savings: FCP 0 ms, LCP 0 ms
139+
134140
## External resources:
135141
- https://web.dev/articles/lcp
136142
- https://web.dev/articles/optimize-lcp`;
@@ -164,6 +170,8 @@ allUrls = [0: https://code.jquery.com/jquery-3.7.1.js, 1: http://localhost:8000/
164170
2;581.60 ms;583.11 ms;1,192.93 ms;1,193.16 ms;611.56 ms;0.19 ms;0.23 ms;200;text/css;VeryHigh;VeryHigh;VeryHigh;t;http/1.0;f;1;[];[Content-Length: <redacted>|Date: Fri, 07 Mar 2025 15:02:28 GMT|Content-type: text/css|Last-Modified: Fri, 07 Mar 2025 14:58:07 GMT|Server: SimpleHTTP/0.6 Python/3.9.6]
165171
3;581.56 ms;583.25 ms;1,176.60 ms;1,177.86 ms;596.30 ms;0.36 ms;1.27 ms;200;text/javascript;High;High;High;t;http/1.0;f;1;[];[Content-Length: <redacted>|Date: Fri, 07 Mar 2025 15:02:28 GMT|Content-type: text/javascript|Last-Modified: Fri, 07 Mar 2025 15:00:28 GMT|Server: SimpleHTTP/0.6 Python/3.9.6]
166172
173+
## Estimated savings: FCP 2015 ms, LCP 0 ms
174+
167175
## External resources:
168176
- https://web.dev/articles/lcp
169177
- https://web.dev/articles/optimize-lcp`;
@@ -205,6 +213,8 @@ The result of the checks for this insight are:
205213
- lazy load not applied: PASSED
206214
- Request is discoverable in initial document: PASSED
207215
216+
## Estimated savings: none
217+
208218
## External resources:
209219
- https://web.dev/articles/lcp
210220
- https://web.dev/articles/optimize-lcp`;
@@ -247,6 +257,8 @@ The result of the checks for this insight are:
247257
- Server responded quickly: FAILED
248258
- Compression was applied: FAILED
249259
260+
## Estimated savings: FCP 3428 ms, LCP 3428 ms
261+
250262
## External resources:
251263
- https://web.dev/articles/optimize-ttfb`;
252264

@@ -300,6 +312,8 @@ Layout shifts in this cluster:
300312
- Score: 0.3396
301313
- No potential root causes identified
302314
315+
## Estimated savings: none
316+
303317
## External resources:
304318
- https://wdeb.dev/articles/cls
305319
- https://web.dev/articles/optimize-cls`;
@@ -339,6 +353,8 @@ The longest interaction on the page was a \`click\` which had a total duration o
339353
2. Processing duration: 977.00 ms
340354
3. Presentation delay: 1.97 ms.
341355
356+
## Estimated savings: none
357+
342358
## External resources:
343359
- https://web.dev/articles/inp
344360
- https://web.dev/explore/how-to-optimize-inp
@@ -373,6 +389,8 @@ To pass this insight, ensure your server supports and prioritizes a modern HTTP
373389
## Detailed analysis:
374390
There are no requests that were served over a legacy HTTP protocol.
375391
392+
## Estimated savings: none
393+
376394
## External resources:
377395
- https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2`;
378396
assert.strictEqual(output.trim(), expected.trim());
@@ -414,6 +432,8 @@ allUrls = [0: https://ads.jetpackdigital.com/sites/_uploads/1742278386bg_opt_640
414432
6;8.43 ms;24.40 ms;38.53 ms;38.71 ms;30.28 ms;0.10 ms;0.18 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|x-amz-meta-jets3t-original-file-date-iso8601: <redacted>|ETag: <redacted>|x-amz-meta-md5-hash: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
415433
7;8.44 ms;24.87 ms;37.75 ms;38.00 ms;29.56 ms;0.23 ms;0.25 ms;200;image/gif;Low;Low;Low;f;http/1.1;f;1;[];[x-amz-id-2: <redacted>|x-amz-meta-jets3t-original-file-date-iso8601: <redacted>|ETag: <redacted>|x-amz-meta-md5-hash: <redacted>|Connection: keep-alive|Access-Control-Allow-Methods: GET,HEAD,POST|x-amz-request-id: <redacted>|Accept-Ranges: bytes|Access-Control-Allow-Origin: *|Content-Length: <redacted>|Date: Thu, 20 Mar 2025 19:45:22 GMT|Last-Modified: Tue, 24 Jan 2023 19:54:47 GMT|Content-Type: image/gif|Server: AmazonS3|x-amz-server-side-encryption: <redacted>]
416434
435+
## Estimated savings: FCP 0 ms, LCP 0 ms
436+
417437
## External resources:
418438
- https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2`;
419439
assert.strictEqual(output.trim(), expected.trim());
@@ -674,6 +694,8 @@ Duplication grouped by Node modules: - Source: node_modules/filestack-js - Dupli
674694
- Source: node_modules/css-loader - Duplicated bytes: 1608 bytes
675695
- Source: node_modules/mini-create-react-context - Duplicated bytes: 1563 bytes
676696
697+
## Estimated savings: FCP 100 ms, LCP 100 ms
698+
677699
## External resources:
678700
`;
679701
assertStringEquals(output, expected);
@@ -696,6 +718,8 @@ This insight identifies large, duplicated JavaScript modules that are present in
696718
## Detailed analysis:
697719
There is no duplicated JavaScript in the page modules
698720
721+
## Estimated savings: none
722+
699723
## External resources:
700724
`;
701725
assertStringEquals(output, expected);
@@ -721,6 +745,8 @@ Polyfills and transforms enable older browsers to use new JavaScript features. H
721745
## Detailed analysis:
722746
There is no significant amount of legacy JavaScript on the page.
723747
748+
## Estimated savings: none
749+
724750
## External resources:
725751
- https://web.dev/articles/baseline-and-polyfills
726752
- https://philipwalton.com/articles/the-state-of-es5-on-the-web/`;
@@ -792,6 +818,8 @@ Matches:
792818
Line: 0, Column: 390544, Name: Object.entries
793819
Line: 0, Column: 390688, Name: Object.values
794820
821+
## Estimated savings: FCP 0 ms, LCP 0 ms
822+
795823
## External resources:
796824
- https://web.dev/articles/baseline-and-polyfills
797825
- https://philipwalton.com/articles/the-state-of-es5-on-the-web/`;

front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ ${this.#description()}
118118
${header} Detailed analysis:
119119
${this.#details()}
120120
121+
${header} Estimated savings: ${this.#estimatedSavings() || 'none'}
122+
121123
${header} External resources:
122124
${this.#links()}`;
123125
}
@@ -322,6 +324,17 @@ ${filesFormatted}`;
322324
return '';
323325
}
324326

327+
#estimatedSavings(): string {
328+
return Object.entries(this.#insight.metricSavings ?? {})
329+
.map(([k, v]) => {
330+
if (k === 'CLS') {
331+
return `${k} ${v}`;
332+
}
333+
return `${k} ${v} ms`;
334+
})
335+
.join(', ');
336+
}
337+
325338
#links(): string {
326339
switch (this.#insight.insightKey) {
327340
case 'CLSCulprits':

0 commit comments

Comments
 (0)