From 26d3857c6d85fc760ecf61276b5ffd6c61199a14 Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Tue, 24 Mar 2009 21:19:55 +0000 Subject: Add a new histogram macro to replace a few explicit calls. There is no real change in functionality. Review URL: http://codereview.chromium.org/42514 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12400 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/backend_impl.cc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'net/disk_cache/backend_impl.cc') diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index 9216d22..f106534 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -23,6 +23,10 @@ using base::Time; using base::TimeDelta; +// HISTOGRAM_HOURS will collect time related data with a granularity of hours +// and normal values of a few months. +#define UMA_HISTOGRAM_HOURS UMA_HISTOGRAM_COUNTS_10000 + namespace { const wchar_t* kIndexName = L"index"; @@ -700,15 +704,11 @@ void BackendImpl::FirstEviction() { DCHECK(data_->header.create_time); Time create_time = Time::FromInternalValue(data_->header.create_time); - static Histogram counter("DiskCache.FillupAge", 1, 10000, 50); - counter.SetFlags(kUmaTargetedHistogramFlag); - counter.Add((Time::Now() - create_time).InHours()); - + UMA_HISTOGRAM_HOURS("DiskCache.FillupAge", + (Time::Now() - create_time).InHours()); + int64 use_hours = stats_.GetCounter(Stats::TIMER) / 120; - static Histogram counter2("DiskCache.FillupTime", 1, 10000, 50); - counter2.SetFlags(kUmaTargetedHistogramFlag); - counter2.Add(static_cast(use_hours)); - + UMA_HISTOGRAM_HOURS("DiskCache.FillupTime", static_cast(use_hours)); UMA_HISTOGRAM_PERCENTAGE("DiskCache.FirstHitRatio", stats_.GetHitRatio()); int avg_size = data_->header.num_bytes / GetEntryCount(); @@ -1306,18 +1306,13 @@ void BackendImpl::ReportStats() { // that event, start reporting this: int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; - static Histogram counter("DiskCache.TotalTime", 1, 10000, 50); - counter.SetFlags(kUmaTargetedHistogramFlag); - counter.Add(static_cast(total_hours)); - + UMA_HISTOGRAM_HOURS("DiskCache.TotalTime", static_cast(total_hours)); + int64 use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; if (!use_hours || !GetEntryCount() || !data_->header.num_bytes) return; - static Histogram counter2("DiskCache.UseTime", 1, 10000, 50); - counter2.SetFlags(kUmaTargetedHistogramFlag); - counter2.Add(static_cast(use_hours)); - + UMA_HISTOGRAM_HOURS("DiskCache.UseTime", static_cast(use_hours)); UMA_HISTOGRAM_PERCENTAGE("DiskCache.HitRatio", stats_.GetHitRatio()); UMA_HISTOGRAM_PERCENTAGE("DiskCache.ResurrectRatio", stats_.GetResurrectRatio()); -- cgit v1.1