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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor_unittest.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
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
index b21c918b8eb356b135f376a00e4f3762e6ac0379..2fac583f27da123d52438cb14602f5a3f1ce3c2d 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor_unittest.cc
@@ -1601,6 +1601,31 @@ TEST_F(ResourcePrefetchPredictorTest, TestPrecisionRecallHistograms) {
internal::kResourcePrefetchPredictorRecallHistogram, 50, 1);
histogram_tester_->ExpectBucketCount(
internal::kResourcePrefetchPredictorPrecisionHistogram, 33, 1);
+ histogram_tester_->ExpectBucketCount(
+ internal::kResourcePrefetchPredictorCountHistogram, 3, 1);
+}
+
+TEST_F(ResourcePrefetchPredictorTest, TestPrefetchingDurationHistogram) {
+ // Prefetching duration for an url without resources in the database
+ // shouldn't be recorded.
+ const std::string main_frame_url = "http://google.com/?query=cats";
+ predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL);
+ predictor_->StopPrefetching(GURL(main_frame_url));
+ histogram_tester_->ExpectTotalCount(
+ internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 0);
+
+ // Fill the database to record a duration.
+ PrefetchData google = CreatePrefetchData("google.com", 1);
+ InitializeResourceData(
+ google.add_resources(), "https://cdn.google.com/script.js",
+ content::RESOURCE_TYPE_SCRIPT, 10, 0, 1, 2.1, net::MEDIUM, false, false);
+ predictor_->host_table_cache_->insert(
+ std::make_pair(google.primary_key(), google));
+
+ predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL);
+ predictor_->StopPrefetching(GURL(main_frame_url));
+ histogram_tester_->ExpectTotalCount(
+ internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1);
}
} // namespace predictors
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698