0

[ios] Add IOS.MagicStack.Start/NTP.SegmentationRankingFetchTime

These metrics will measure the fetch time for the Magic Stack
Segmentation ranking to validate hypothesis that Start fetches take
much longer.

Change-Id: I3aa3a9ae83e958768ce831426bc95d86b74e0896
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5530559
Reviewed-by: Guillem Perez <guiperez@google.com>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1299600}
This commit is contained in:
Chris Lu
2024-05-10 23:46:11 +00:00
committed by Chromium LUCI CQ
parent c857c9e922
commit 59c5953c9f
5 changed files with 44 additions and 0 deletions

@ -31,4 +31,9 @@ extern const char kMagicStackModuleEngagementSafetyCheckIndexHistogram[];
extern const char kMagicStackModuleEngagementParcelTrackingIndexHistogram[];
extern const char kContentNotificationSnackbarEventHistogram[];
// The name of the histogram that records fetch time for the Segmentation
// ranking for Magic Stack.
extern const char kMagicStackStartSegmentationRankingFetchTimeHistogram[];
extern const char kMagicStackNTPSegmentationRankingFetchTimeHistogram[];
#endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_METRICS_CONSTANTS_H_

@ -39,3 +39,8 @@ const char kMagicStackModuleEngagementParcelTrackingIndexHistogram[] =
"IOS.MagicStack.Module.Click.ParcelTracking";
const char kContentNotificationSnackbarEventHistogram[] =
"ContentNotifications.Promo.Snackbar.Event";
const char kMagicStackStartSegmentationRankingFetchTimeHistogram[] =
"IOS.MagicStack.Start.SegmentationRankingFetchTime";
const char kMagicStackNTPSegmentationRankingFetchTimeHistogram[] =
"IOS.MagicStack.NTP.SegmentationRankingFetchTime";

@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_ranking_model.h"
#import "base/metrics/histogram_macros.h"
#import "components/segmentation_platform/public/constants.h"
#import "components/segmentation_platform/public/features.h"
#import "components/segmentation_platform/public/segmentation_platform_service.h"
@ -19,6 +20,7 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/shortcuts_mediator.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_consumer.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_metrics_constants.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_metrics_recorder.h"
#import "ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_ranking_model_delegate.h"
#import "ios/chrome/browser/ui/content_suggestions/magic_stack/most_visited_tiles_config.h"
@ -65,6 +67,7 @@
ParcelTrackingMediator* _parcelTrackingMediator;
ShortcutsMediator* _shortcutsMediator;
SafetyCheckMagicStackMediator* _safetyCheckMediator;
base::TimeTicks ranking_fetch_start_time_;
}
- (instancetype)initWithSegmentationService:
@ -365,6 +368,7 @@
} else {
options.on_demand_execution = true;
}
ranking_fetch_start_time_ = base::TimeTicks::Now();
_segmentationService->GetClassificationResult(
segmentation_platform::kIosModuleRankerKey, options, inputContext,
base::BindOnce(
@ -380,6 +384,14 @@
return;
}
if ([self.homeStartDataSource isStartSurface]) {
LOCAL_HISTOGRAM_TIMES(kMagicStackStartSegmentationRankingFetchTimeHistogram,
base::TimeTicks::Now() - ranking_fetch_start_time_);
} else {
LOCAL_HISTOGRAM_TIMES(kMagicStackNTPSegmentationRankingFetchTimeHistogram,
base::TimeTicks::Now() - ranking_fetch_start_time_);
}
NSMutableArray* magicStackOrder = [NSMutableArray array];
for (const std::string& label : result.ordered_labels) {
if (label == segmentation_platform::kMostVisitedTiles) {

@ -37,6 +37,7 @@
#import "ios/chrome/browser/ui/content_suggestions/cells/shortcuts_mediator.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_consumer.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_metrics_constants.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_metrics_recorder.h"
#import "ios/chrome/browser/ui/content_suggestions/magic_stack/magic_stack_ranking_model_delegate.h"
#import "ios/chrome/browser/ui/content_suggestions/parcel_tracking/parcel_tracking_item.h"
@ -348,6 +349,8 @@ TEST_F(MagicStackRankingModelTest, TestMagicStackOrderSegmentationServiceCall) {
return _magicStackRankingModel.hasReceivedMagicStackResponse;
}));
EXPECT_OCMOCK_VERIFY(consumer_);
histogram_tester_->ExpectTotalCount(
kMagicStackNTPSegmentationRankingFetchTimeHistogram, 1);
}
// Tests that the -setMagicStackOrder: consumer call is executed with the

@ -1594,6 +1594,25 @@ the generic promo launch. -->
</summary>
</histogram>
<histogram name="IOS.MagicStack.NTP.SegmentationRankingFetchTime" units="ms"
expires_after="2024-11-03">
<owner>thegreenfrog@chromium.org</owner>
<owner>bling-get-set-up@google.com</owner>
<summary>
Records the fetch time for the Segmentation ranking for Magic Stack on NTP.
</summary>
</histogram>
<histogram name="IOS.MagicStack.Start.SegmentationRankingFetchTime" units="ms"
expires_after="2024-11-03">
<owner>thegreenfrog@chromium.org</owner>
<owner>bling-get-set-up@google.com</owner>
<summary>
Records the fetch time for the Segmentation ranking for Magic Stack on
Start.
</summary>
</histogram>
<histogram name="IOS.MainFrameNavigationIsInBrowserLockdownMode" enum="Boolean"
expires_after="2024-11-03">
<owner>joemerramos@chromium.org</owner>