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

Side by Side 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, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/history/core/browser/thumbnail_database.h" 5 #include "components/history/core/browser/thumbnail_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 if (status == sql::INIT_OK) 606 if (status == sql::INIT_OK)
607 return status; 607 return status;
608 608
609 meta_table_.Reset(); 609 meta_table_.Reset();
610 db_.Close(); 610 db_.Close();
611 } 611 }
612 return status; 612 return status;
613 } 613 }
614 614
615 void ThumbnailDatabase::ComputeDatabaseMetrics() { 615 void ThumbnailDatabase::ComputeDatabaseMetrics() {
616 sql::Statement favicon_count( 616 base::TimeTicks start_time = base::TimeTicks::Now();
617 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons")); 617
618 UMA_HISTOGRAM_COUNTS_10000( 618 // Calculate the size of the favicon database.
619 "History.NumFaviconsInDB", 619 {
620 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0); 620 sql::Statement page_count(
621 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_count"));
622 int64 page_count_bytes = page_count.Step() ? page_count.ColumnInt64(0) : 0;
623 sql::Statement page_size(
624 db_.GetCachedStatement(SQL_FROM_HERE, "PRAGMA page_size"));
625 int64 page_size_bytes = page_size.Step() ? page_size.ColumnInt64(0) : 0;
626 int size_mb = static_cast<int>(
627 (page_count_bytes * page_size_bytes) / (1024 * 1024));
628 UMA_HISTOGRAM_MEMORY_MB("History.FaviconDatabaseSizeMB", size_mb);
629 }
630
631 // Count all icon files referenced by the DB.
632 {
633 sql::Statement favicon_count(
634 db_.GetCachedStatement(SQL_FROM_HERE, "SELECT COUNT(*) FROM favicons"));
635 UMA_HISTOGRAM_COUNTS_10000(
636 "History.NumFaviconsInDB",
637 favicon_count.Step() ? favicon_count.ColumnInt(0) : 0);
638 }
639
640 // Count all bitmap resources cached in the DB.
641 {
642 sql::Statement bitmap_count(
643 db_.GetCachedStatement(
644 SQL_FROM_HERE, "SELECT COUNT(*) FROM favicon_bitmaps"));
645 UMA_HISTOGRAM_COUNTS_10000(
646 "History.NumFaviconBitmapsInDB",
647 bitmap_count.Step() ? bitmap_count.ColumnInt(0) : 0);
648 }
649
650 // Count the subset of "large" icon files referenced by the DB. We define
651 // "large" icon files all types other than INVALID_ICON and FAVICON, for
652 // which we usually store only small (16x16 or 32x32) bitmaps by default.
653 {
654 sql::Statement large_favicon_count(
655 db_.GetCachedStatement(
656 SQL_FROM_HERE,
657 "SELECT COUNT(*) FROM favicons WHERE icon_type not in (?, ?)"));
658 large_favicon_count.BindInt64(0, favicon_base::INVALID_ICON);
659 large_favicon_count.BindInt64(0, favicon_base::FAVICON);
660 UMA_HISTOGRAM_COUNTS_10000(
661 "History.NumLargeFaviconsInDB",
662 large_favicon_count.Step() ? large_favicon_count.ColumnInt(0) : 0);
663 }
664
665 // Count the subset of "large" bitmap resources cached in the DB.
666 {
667 sql::Statement large_bitmap_count(
668 db_.GetCachedStatement(
669 SQL_FROM_HERE,
670 "SELECT COUNT(*) FROM favicon_bitmaps WHERE width >= 64"));
671 UMA_HISTOGRAM_COUNTS_10000(
672 "History.NumLargeFaviconBitmapsInDB",
673 large_bitmap_count.Step() ? large_bitmap_count.ColumnInt(0) : 0);
674 }
675
676 // Count all icon mappings maintained by the DB.
677 {
678 sql::Statement mapping_count(
679 db_.GetCachedStatement(
680 SQL_FROM_HERE,
681 "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.
682 UMA_HISTOGRAM_COUNTS_10000(
683 "History.NumFaviconsMappingsInDB",
684 mapping_count.Step() ? mapping_count.ColumnInt(0) : 0);
685 }
686
687 UMA_HISTOGRAM_TIMES("History.FaviconDatabaseAdvancedMetricsTime",
688 base::TimeTicks::Now() - start_time);
621 } 689 }
622 690
623 void ThumbnailDatabase::BeginTransaction() { 691 void ThumbnailDatabase::BeginTransaction() {
624 db_.BeginTransaction(); 692 db_.BeginTransaction();
625 } 693 }
626 694
627 void ThumbnailDatabase::CommitTransaction() { 695 void ThumbnailDatabase::CommitTransaction() {
628 db_.CommitTransaction(); 696 db_.CommitTransaction();
629 } 697 }
630 698
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 meta_table_.SetVersionNumber(7); 1366 meta_table_.SetVersionNumber(7);
1299 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber)); 1367 meta_table_.SetCompatibleVersionNumber(std::min(7, kCompatibleVersionNumber));
1300 return true; 1368 return true;
1301 } 1369 }
1302 1370
1303 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1371 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1304 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1372 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1305 } 1373 }
1306 1374
1307 } // namespace history 1375 } // namespace history
OLDNEW
« 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