Skip to content

Commit 0227afd

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
Include basic end-to-end request duration for developer resources
[email protected] Bug: None Change-Id: I90fce3be9daf1cb2f066c2190795f20ad063aea8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6304711 Commit-Queue: Simon Zünd <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent c3ac16f commit 0227afd

File tree

7 files changed

+20
-2
lines changed

7 files changed

+20
-2
lines changed

front_end/core/sdk/PageResourceLoader.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describeWithLocale('PageResourceLoader', () => {
6666
success: true,
6767
initiator,
6868
size: null,
69+
duration: null,
6970
};
7071

7172
loader.resourceLoadedThroughExtension(extensionResource);

front_end/core/sdk/PageResourceLoader.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface PageResource {
5656
initiator: PageResourceLoadInitiator;
5757
url: Platform.DevToolsPath.UrlString;
5858
size: number|null;
59+
duration: number|null;
5960
}
6061

6162
// Used for revealing a resource.
@@ -255,9 +256,11 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
255256
throw new Error('Invalid initiator');
256257
}
257258
const key = PageResourceLoader.makeKey(url, initiator);
258-
const pageResource: PageResource = {success: null, size: null, errorMessage: undefined, url, initiator};
259+
const pageResource:
260+
PageResource = {success: null, size: null, duration: null, errorMessage: undefined, url, initiator};
259261
this.#pageResources.set(key, pageResource);
260262
this.dispatchEventToListeners(Events.UPDATE);
263+
const startTime = performance.now();
261264
try {
262265
await this.acquireLoadSlot(initiator.target);
263266
const resultPromise = this.dispatchLoad(url, initiator);
@@ -278,6 +281,7 @@ export class PageResourceLoader extends Common.ObjectWrapper.ObjectWrapper<Event
278281
}
279282
throw e;
280283
} finally {
284+
pageResource.duration = performance.now() - startTime;
281285
this.releaseLoadSlot(initiator.target);
282286
this.dispatchEventToListeners(Events.UPDATE);
283287
}

front_end/models/extensions/ExtensionServer.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ describeWithDevtoolsExtension('Language Extension API', {}, context => {
912912
initiator: expectedInitiator,
913913
success: true,
914914
size: 10,
915+
duration: null,
915916
errorMessage: undefined,
916917
};
917918
assert.deepEqual(resource, expectedResource);

front_end/models/extensions/ExtensionServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ export class ExtensionServer extends Common.ObjectWrapper.ObjectWrapper<EventTyp
443443
errorMessage: status.errorMessage,
444444
success: status.success ?? null,
445445
size: status.size ?? null,
446+
duration: null,
446447
};
447448
SDK.PageResourceLoader.PageResourceLoader.instance().resourceLoadedThroughExtension(pageResource);
448449
return this.status.OK();

front_end/panels/developer_resources/DeveloperResourcesListView.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const UIStrings = {
3232
*@description Text in Coverage List View of the Coverage tab
3333
*/
3434
totalBytes: 'Total Bytes',
35+
/**
36+
* @description Column header. The column contains the time it took to load a resource.
37+
*/
38+
duration: 'Duration',
3539
/**
3640
*@description Text for errors
3741
*/
@@ -112,6 +116,9 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
112116
<th id="size" sortable fixed width="80px" align="right">
113117
${i18nString(UIStrings.totalBytes)}
114118
</th>
119+
<th id="duration" sortable fixed width="80px" align="right">
120+
${i18nString(UIStrings.duration)}
121+
</th>
115122
<th id="error-message" sortable width="200px">
116123
${i18nString(UIStrings.error)}
117124
</th>
@@ -136,6 +143,9 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
136143
<td aria-label=${item.size !== null ? i18nString(UIStrings.sBytes, {n: item.size}) : nothing}
137144
data-value=${item.size ?? nothing}>${
138145
item.size !== null ? html`<span>${withThousandsSeparator(item.size)}</span>` : ''}</td>
146+
<td aria-label=${item.duration !== null ? i18n.TimeUtilities.millisToString(item.duration) : nothing}
147+
data-value=${item.duration ?? nothing}>${
148+
item.duration !== null ? html`<span>${i18n.TimeUtilities.millisToString(item.duration)}</span>` : ''}</td>
139149
<td class="error-message">${(() => {
140150
const cell = document.createElement('span');
141151
if (item.errorMessage) {

front_end/panels/developer_resources/DeveloperResourcesView.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describeWithEnvironment('DeveloperResourcesView', () => {
1515
const extensionId = 'extensionId';
1616
const initiator = {target: null, frameId: null, extensionId, initiatorUrl: urlString`${extensionId}`};
1717

18-
const commonInfo = {success: true, initiator, size: 10};
18+
const commonInfo = {success: true, initiator, size: 10, duration: 20};
1919
const resource1 = {url: urlString`http://www.test.com/test.js`, ...commonInfo};
2020
const resource2 = {url: urlString`http://www.test.com/test2.js`, ...commonInfo};
2121
const resource3 = {url: urlString`http://www.test.com/test3.js`, ...commonInfo};

test/e2e/extensions/debugger-language-plugins_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ describe('The Debugger Language Plugins', () => {
672672
dwoUrl,
673673
initiatorUrl,
674674
'',
675+
'',
675676
'404',
676677
'',
677678
]);

0 commit comments

Comments
 (0)