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

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: simplify metric queries + add a historgram for number of url mappings being tracked 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') | no next file with comments »
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..724b4a6eaf7517abbaa86ffd4d5618a5b23579b8 100644
--- a/components/history/core/browser/thumbnail_database.cc
+++ b/components/history/core/browser/thumbnail_database.cc
@@ -613,11 +613,79 @@ 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 files 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 "large" icon files referenced by the DB. We define
+ // "large" icon files all types other than INVALID_ICON and FAVICON, for
+ // which we usually store only small (16x16 or 32x32) bitmaps by default.
+ {
+ sql::Statement large_favicon_count(
+ db_.GetCachedStatement(
+ SQL_FROM_HERE,
+ "SELECT COUNT(*) FROM favicons WHERE icon_type not in (?, ?)"));
+ large_favicon_count.BindInt64(0, favicon_base::INVALID_ICON);
+ large_favicon_count.BindInt64(0, favicon_base::FAVICON);
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumLargeFaviconsInDB",
+ large_favicon_count.Step() ? large_favicon_count.ColumnInt(0) : 0);
+ }
+
+ // Count the subset of "large" bitmap resources cached in the DB.
+ {
+ 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"));
beaudoin 2015/03/26 19:36:28 Nit: don't wrap.
Roger McFarlane (Chromium) 2015/03/27 03:45:02 Done.
+ UMA_HISTOGRAM_COUNTS_10000(
+ "History.NumFaviconsMappingsInDB",
+ mapping_count.Step() ? mapping_count.ColumnInt(0) : 0);
+ }
+
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698