Skip to content

Commit 363c4a9

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Sort in ImageDelivery model
Also now sorting by image byte savings, rather than image size. Drive-by formatting fix for ForcedReflow component. Bug: 388723721 Change-Id: Ia1e511006a343c64283915f09db075670fd39fb5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6237241 Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Connor Clark <[email protected]> Reviewed-by: Adam Raine <[email protected]> Commit-Queue: Adam Raine <[email protected]>
1 parent bbd6d69 commit 363c4a9

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

front_end/models/trace/insights/ImageDelivery.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ describeWithEnvironment('ImageDelivery', function() {
5959
url:
6060
'https://raw.githubusercontent.com/GoogleChrome/lighthouse/refs/heads/main/cli/test/fixtures/dobetterweb/lighthouse-rotating.gif',
6161
},
62+
{
63+
byteSavings: 176040,
64+
optimizations: [
65+
{
66+
byteSavings: 134075,
67+
type: ImageOptimizationType.MODERN_FORMAT_OR_COMPRESSION,
68+
},
69+
{
70+
byteSavings: 162947,
71+
type: ImageOptimizationType.RESPONSIVE_SIZE,
72+
fileDimensions: {width: 640, height: 436},
73+
displayDimensions: {width: 200, height: 136},
74+
},
75+
],
76+
url: 'https://onlinepngtools.com/images/examples-onlinepngtools/elephant-hd-quality.png',
77+
},
6278
{
6379
byteSavings: 49760,
6480
optimizations: [
@@ -83,22 +99,6 @@ describeWithEnvironment('ImageDelivery', function() {
8399
url:
84100
'https://raw.githubusercontent.com/GoogleChrome/lighthouse/refs/heads/main/cli/test/fixtures/byte-efficiency/lighthouse-2048x1356.webp',
85101
},
86-
{
87-
byteSavings: 176040,
88-
optimizations: [
89-
{
90-
byteSavings: 134075,
91-
type: ImageOptimizationType.MODERN_FORMAT_OR_COMPRESSION,
92-
},
93-
{
94-
byteSavings: 162947,
95-
type: ImageOptimizationType.RESPONSIVE_SIZE,
96-
fileDimensions: {width: 640, height: 436},
97-
displayDimensions: {width: 200, height: 136},
98-
},
99-
],
100-
url: 'https://onlinepngtools.com/images/examples-onlinepngtools/elephant-hd-quality.png',
101-
},
102102
],
103103
);
104104
});

front_end/models/trace/insights/ImageDelivery.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export interface OptimizableImage {
127127
}
128128

129129
export type ImageDeliveryInsightModel = InsightModel<typeof UIStrings, {
130+
/** Sorted by potential byte savings, then by size of image. */
130131
optimizableImages: OptimizableImage[],
131132
totalByteSavings: number,
132133
}>;
@@ -284,6 +285,15 @@ export function generateInsight(
284285
wastedBytesByRequestId.set(image.request.args.data.requestId, image.byteSavings);
285286
}
286287

288+
// Sort by savings, then by size of image.
289+
optimizableImages.sort((a, b) => {
290+
if (b.byteSavings !== a.byteSavings) {
291+
return b.byteSavings - a.byteSavings;
292+
}
293+
294+
return b.request.args.data.decodedBodyLength - a.request.args.data.decodedBodyLength;
295+
});
296+
287297
return finalize({
288298
optimizableImages,
289299
totalByteSavings: optimizableImages.reduce((total, img) => total + img.byteSavings, 0),

front_end/panels/timeline/components/insights/ForcedReflow.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,25 @@ export class ForcedReflow extends BaseInsightComponent<ForcedReflowInsightModel>
5656
// clang-format off
5757
return html`
5858
<div class="insight-section">
59-
${html`<devtools-performance-table
59+
<devtools-performance-table
6060
.data=${{
6161
insight: this,
6262
headers: [i18nString(UIStrings.topTimeConsumingFunctionCall), i18nString(UIStrings.totalReflowTime)],
6363
rows: [{values:[this.#linkifyUrl(topLevelFunctionCallData), time(Trace.Types.Timing.Micro(totalReflowTime))]}],
64-
} as TableData}>
65-
</devtools-performance-table>`}
64+
} as TableData}>
65+
</devtools-performance-table>
6666
</div>
6767
<div class="insight-section">
68-
${html`<devtools-performance-table
69-
.data=${{
70-
insight: this,
71-
headers: [i18nString(UIStrings.relatedStackTrace)],
72-
rows: bottomUpCallStackData.map(data => ({
73-
values: [this.#linkifyUrl(data.bottomUpData)],
74-
overlays: this.#createOverlayForEvents(data.relatedEvents),
75-
})),
68+
<devtools-performance-table
69+
.data=${{
70+
insight: this,
71+
headers: [i18nString(UIStrings.relatedStackTrace)],
72+
rows: bottomUpCallStackData.map(data => ({
73+
values: [this.#linkifyUrl(data.bottomUpData)],
74+
overlays: this.#createOverlayForEvents(data.relatedEvents),
75+
})),
7676
} as TableData}>
77-
</devtools-performance-table>`}
77+
</devtools-performance-table>
7878
</div>`;
7979
// clang-format on
8080
}

0 commit comments

Comments
 (0)