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 fd16f7563f8a905075631f1aafbd570cbeae9aee..45bf29909501786c766f88b34faf5f0f0d246a98 100644 |
--- a/components/history/core/browser/thumbnail_database.cc |
+++ b/components/history/core/browser/thumbnail_database.cc |
@@ -619,11 +619,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 "touch" icon URLs referenced by the DB. |
+ { |
+ sql::Statement touch_icon_count( |
+ db_.GetCachedStatement( |
+ SQL_FROM_HERE, |
+ "SELECT COUNT(*) FROM favicons WHERE icon_type IN (?, ?)")); |
+ 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 "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")); |
+ 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() { |