Skip to content

Commit

Permalink
Measure the time spent opening an existing tab
Browse files Browse the repository at this point in the history
This CL adds a time histogram to measure how long it took for the user
to select an existing time in the tab switcher. If the user opens a new
tab or closes the tab switcher, it is not recorded.

Fixed: 1440186
Change-Id: I1b312978444be13a96796d8665941781dc57738c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4482554
Reviewed-by: Gauthier Ambard <[email protected]>
Reviewed-by: Olivier Robin <[email protected]>
Commit-Queue: Louis Romero <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1136465}
  • Loading branch information
Arcank authored and Chromium LUCI CQ committed Apr 27, 2023
1 parent e687df1 commit 285d8d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ @interface TabGridViewController () <DisabledTabViewControllerDelegate,
// YES if it is possible to undo the close all conditions.
@property(nonatomic, assign) BOOL undoCloseAllAvailable;

// The timestamp of the user entering the tab grid.
@property(nonatomic, assign) base::TimeTicks tabGridEnterTime;

@end

@implementation TabGridViewController {
Expand Down Expand Up @@ -509,6 +512,9 @@ - (void)contentWillAppearAnimated:(BOOL)animated {
self.remoteTabsViewController.session = self.view.window.windowScene.session;

self.remoteTabsViewController.preventUpdates = NO;

// Record when the tab switcher is presented.
self.tabGridEnterTime = base::TimeTicks::Now();
}

- (void)contentDidAppear {
Expand Down Expand Up @@ -548,6 +554,8 @@ - (void)contentWillDisappearAnimated:(BOOL)animated {
[self.regularTabsViewController contentWillDisappear];
[self.pinnedTabsViewController contentWillDisappear];
self.remoteTabsViewController.preventUpdates = YES;

self.tabGridEnterTime = base::TimeTicks();
}

- (void)dismissModals {
Expand Down Expand Up @@ -2203,6 +2211,14 @@ - (void)updateToolbarsAppearance {
[self.bottomToolbar setScrollViewScrolledToEdge:gridScrolledToBottom];
}

- (void)reportTabSelectionTime {
CHECK(!self.tabGridEnterTime.is_null());
base::TimeDelta duration = base::TimeTicks::Now() - self.tabGridEnterTime;
base::UmaHistogramLongTimes("IOS.TabSwitcher.TimeSpentOpeningExistingTab",
duration);
self.tabGridEnterTime = base::TimeTicks();
}

#pragma mark UIGestureRecognizerDelegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
Expand Down Expand Up @@ -2399,6 +2415,9 @@ - (void)thumbStripDisabled {
- (void)pinnedTabsViewController:
(PinnedTabsViewController*)pinnedTabsViewController
didSelectItemWithID:(NSString*)itemID {
// Record how long it took to select an item.
[self reportTabSelectionTime];

[self.pinnedTabsDelegate selectItemWithID:itemID];

self.activePage = self.currentPage;
Expand Down Expand Up @@ -2491,6 +2510,8 @@ - (void)gridViewController:(GridViewController*)gridViewController
base::UserMetricsAction("MobileTabGridOpenIncognitoTabSearchResult"));
}
}
// Record how long it took to select an item.
[self reportTabSelectionTime];

alreadySelected = [tabsDelegate isItemWithIDSelected:itemID];
if (!alreadySelected) {
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/metadata/ios/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,17 @@ [email protected].
</summary>
</histogram>

<histogram name="IOS.TabSwitcher.TimeSpentOpeningExistingTab" units="ms"
expires_after="2024-05-14">
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<owner>[email protected]</owner>
<summary>
The time it takes for a user to open an existing tab. If the user opens a
new tab or closes the tab switcher, this is not recorded.
</summary>
</histogram>

<histogram name="IOS.TabSwitcher.TimeSpentScrolling" units="ms"
expires_after="2024-05-14">
<owner>[email protected]</owner>
Expand Down

0 comments on commit 285d8d0

Please sign in to comment.