Chromium Code Reviews| 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..cd88640029659cf7491a03a8aaed315ca9dca349 100644 |
| --- a/components/history/core/browser/thumbnail_database.cc |
| +++ b/components/history/core/browser/thumbnail_database.cc |
| @@ -613,11 +613,67 @@ 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 file_mb = static_cast<int>( |
| + (page_count_bytes * page_size_bytes) / (1024 * 1024)); |
| + UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", file_mb); |
|
Roger McFarlane (Chromium)
2015/03/25 18:20:18
KB?
beaudoin
2015/03/25 18:31:48
+1, MB has an overly large first bin.
|
| + } |
| + |
| + // 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. |
| + { |
| + sql::Statement large_favicon_count( |
| + db_.GetCachedStatement( |
| + SQL_FROM_HERE, |
| + "SELECT COUNT(*) FROM favicons WHERE icon_type > ?")); |
|
beaudoin
2015/03/25 18:31:48
I think I'd prefer something like "width > 64" or
brettw
2015/03/25 19:38:53
Also, I think this allows you to delete the large
Roger McFarlane (Chromium)
2015/03/26 18:26:33
The schema doesn't quite allow for this, but perha
|
| + 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 id IN (SELECT id FROM favicons WHERE icon_type > ?)")); |
| + large_bitmap_count.BindInt64(0, favicon_base::FAVICON); |
| + UMA_HISTOGRAM_COUNTS_10000( |
| + "History.NumLargeFaviconBitmapsInDB", |
| + large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0); |
| + } |
| + |
| + UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime", |
| + base::TimeTicks::Now() - start_time); |
| } |
| void ThumbnailDatabase::BeginTransaction() { |