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

Unified Diff: components/history/core/browser/thumbnail_database.cc

Issue 1032763002: Add favicon database histograms to UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply review feedback. Created 5 years, 9 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/history/core/browser/thumbnail_database.cc
diff --git a/components/history/core/browser/thumbnail_database.cc b/components/history/core/browser/thumbnail_database.cc
index 05a247dc4929d1460821356f19cd9d00a3b8ec87..d5a0b3b3ddd9c674eb7852081e83c4578fd6de02 100644
--- a/components/history/core/browser/thumbnail_database.cc
+++ b/components/history/core/browser/thumbnail_database.cc
@@ -613,11 +613,77 @@ sql::InitStatus ThumbnailDatabase::Init(const base::FilePath& db_name) {
}
void ThumbnailDatabase::ComputeDatabaseMetrics() {
- sql::Statement favicon_count(
- db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons"));
- UMA_HISTOGRAM_COUNTS_10000(
- "History.NumFaviconsInDB",
- favicon_count.Step() ? favicon_count.ColumnInt(0) : 0);
+ base::TimeTicks start_time = base::TimeTicks::Now();
+
+ // Calculate the size of the favicon database.
+ {
+ sql::Statement page_count(
+ db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_count"));
+ int64 page_count_bytes = page_count.Step() ? page_count.ColumnInt64(0) : 0;
+ sql::Statement page_size(
+ db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_size"));
+ int64 page_size_bytes = page_size.Step() ? page_size.ColumnInt64(0) : 0;
+ int size_mb = static_cast<int>(
+ (page_count_bytes * page_size_bytes) / (1024 * 1024));
+ UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", size_mb);
+ }
+
+ // Count all icon URLs referenced by the DB.
+ {
+ sql::Statement favicon_count(
+ db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons"));
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumFaviconsInDB",
+ favicon_count.Step() ? favicon_count.ColumnInt(0) : 0);
+ }
+
+ // Count all bitmap resources cached in the DB.
+ {
+ sql::Statement bitmap_count(
+ db_.GetCachedStatement(
+ SQL_FROM_HERE, "SELECT COUNT(*) FROM favicon_bitmaps"));
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumFaviconBitmapsInDB",
+ bitmap_count.Step() ? bitmap_count.ColumnInt(0) : 0);
+ }
+
+ // Count the subset of "touch" icon URLs referenced by the DB.
pkotwicz 2015/03/30 19:25:19 How about: "Count "touch" icon URLs referenced in
Roger McFarlane (Chromium) 2015/03/31 14:33:10 Done.
+ {
+ sql::Statement touch_icon_count(
+ db_.GetCachedStatement(
+ SQL_FROM_HERE,
+ "SELECT COUNT(*) FROM favicons WHERE icon_type in (?, ?)"));
pkotwicz 2015/03/30 19:25:19 Nit: 'in' -> 'IN'
Roger McFarlane (Chromium) 2015/03/31 14:33:10 Done.
+ touch_icon_count.BindInt64(0, favicon_base::TOUCH_ICON);
+ touch_icon_count.BindInt64(0, favicon_base::TOUCH_PRECOMPOSED_ICON);
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumTouchIconsInDB",
+ touch_icon_count.Step() ? touch_icon_count.ColumnInt(0) : 0);
+ }
+
+ // Count the subset of "large" bitmap resources cached in the DB.
pkotwicz 2015/03/30 19:25:19 How about: "Count "large" bitmap resources cached
Roger McFarlane (Chromium) 2015/03/31 14:33:10 Done.
+ {
+ sql::Statement large_bitmap_count(
+ db_.GetCachedStatement(
+ SQL_FROM_HERE,
+ "SELECT COUNT(*) FROM favicon_bitmaps WHERE width >= 64"));
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumLargeFaviconBitmapsInDB",
+ large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0);
+ }
+
+ // Count all icon mappings maintained by the DB.
+ {
+ sql::Statement mapping_count(
+ db_.GetCachedStatement(
+ SQL_FROM_HERE, "SELECT COUNT(*) FROM icon_mapping"));
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "History.NumFaviconMappingsInDB",
+ (mapping_count.Step() ? mapping_count.ColumnInt(0) : 0),
+ 1, 100000, 100);
+ }
+
+ UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime",
+ base::TimeTicks::Now() - start_time);
}
void ThumbnailDatabase::BeginTransaction() {
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698