Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1476)

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2683633004: predictors: Add subresources count and prefetching duration histograms. (Closed)
Patch Set: Nits. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_predictor.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
index 67dd25aec05b3071e51f0285cd1e853f4d21cc69..41497fe7c9a80dfa85d3a7ee640e583e282d5708 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
@@ -150,6 +150,8 @@ void ReportPredictionAccuracy(
precision_percentage);
UMA_HISTOGRAM_PERCENTAGE(internal::kResourcePrefetchPredictorRecallHistogram,
recall_percentage);
+ UMA_HISTOGRAM_COUNTS_100(internal::kResourcePrefetchPredictorCountHistogram,
+ predicted_urls.size());
}
} // namespace
@@ -506,6 +508,12 @@ void ResourcePrefetchPredictor::StartPrefetching(const GURL& url,
PrefetchOrigin origin) {
TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StartPrefetching", "url",
url.spec());
+ // Save prefetch start time to report prefetching duration.
+ if (inflight_prefetches_.find(url) == inflight_prefetches_.end() &&
+ IsUrlPrefetchable(url)) {
+ inflight_prefetches_.insert(std::make_pair(url, base::TimeTicks::Now()));
+ }
+
if (!prefetch_manager_.get()) // Prefetching not enabled.
return;
if (!config_.IsPrefetchingEnabledForOrigin(profile_, origin))
@@ -524,6 +532,13 @@ void ResourcePrefetchPredictor::StartPrefetching(const GURL& url,
void ResourcePrefetchPredictor::StopPrefetching(const GURL& url) {
TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StopPrefetching", "url",
url.spec());
+ auto it = inflight_prefetches_.find(url);
+ if (it != inflight_prefetches_.end()) {
+ UMA_HISTOGRAM_TIMES(
+ internal::kResourcePrefetchPredictorPrefetchingDurationHistogram,
+ base::TimeTicks::Now() - it->second);
+ inflight_prefetches_.erase(it);
+ }
if (!prefetch_manager_.get()) // Not enabled.
return;
@@ -769,6 +784,14 @@ void ResourcePrefetchPredictor::CleanupAbandonedNavigations(
++it;
}
}
+
+ for (auto it = inflight_prefetches_.begin();
+ it != inflight_prefetches_.end();) {
+ if (time_now - it->second > max_navigation_age)
+ it = inflight_prefetches_.erase(it);
+ else
+ ++it;
+ }
}
void ResourcePrefetchPredictor::DeleteAllUrls() {

Powered by Google App Engine
This is Rietveld 408576698