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

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

Issue 2683633004: predictors: Add subresources count and prefetching duration histograms. (Closed)
Patch Set: Add descriptions to histograms.xml. 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..c17e6e0f5c899babb48b01da0704e5f3e98356c2 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_prefetchings_.find(url) == inflight_prefetchings_.end() &&
+ IsUrlPrefetchable(url)) {
+ inflight_prefetchings_.insert(std::make_pair(url, base::TimeTicks::Now()));
+ }
+
if (!prefetch_manager_.get()) // Prefetching not enabled.
return;
if (!config_.IsPrefetchingEnabledForOrigin(profile_, origin))
@@ -524,6 +532,14 @@ void ResourcePrefetchPredictor::StartPrefetching(const GURL& url,
void ResourcePrefetchPredictor::StopPrefetching(const GURL& url) {
TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StopPrefetching", "url",
url.spec());
+ std::map<GURL, base::TimeTicks>::iterator prefetching_it =
+ inflight_prefetchings_.find(url);
+ if (prefetching_it != inflight_prefetchings_.end()) {
+ UMA_HISTOGRAM_TIMES(
+ internal::kResourcePrefetchPredictorPrefetchingDurationHistogram,
+ base::TimeTicks::Now() - prefetching_it->second);
+ inflight_prefetchings_.erase(prefetching_it);
+ }
if (!prefetch_manager_.get()) // Not enabled.
return;
@@ -769,6 +785,15 @@ void ResourcePrefetchPredictor::CleanupAbandonedNavigations(
++it;
}
}
+
+ for (std::map<GURL, base::TimeTicks>::iterator it =
+ inflight_prefetchings_.begin();
+ it != inflight_prefetchings_.end();) {
+ if (time_now - it->second > max_navigation_age)
+ inflight_prefetchings_.erase(it++);
+ else
+ ++it;
+ }
}
void ResourcePrefetchPredictor::DeleteAllUrls() {

Powered by Google App Engine
This is Rietveld 408576698