summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/histogram.h13
-rw-r--r--net/disk_cache/backend_impl.cc27
-rw-r--r--net/disk_cache/eviction.cc9
3 files changed, 29 insertions, 20 deletions
diff --git a/base/histogram.h b/base/histogram.h
index 7c4b3b8..f189a06 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -41,7 +41,7 @@
//------------------------------------------------------------------------------
// Provide easy general purpose histogram in a macro, just like stats counters.
-// The first two macros use 50 buckets.
+// The first four macros use 50 buckets.
#define HISTOGRAM_TIMES(name, sample) do { \
static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \
@@ -59,6 +59,11 @@
counter.Add(sample); \
} while (0)
+#define HISTOGRAM_COUNTS_10000(name, sample) do { \
+ static Histogram counter((name), 1, 10000, 50); \
+ counter.Add(sample); \
+ } while (0)
+
#define HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \
static LinearHistogram counter((name), 1, 100, 101); \
counter.Add(under_one_hundred); \
@@ -171,6 +176,12 @@ static const int kRendererHistogramFlag = 1 << 4;
counter.Add(sample); \
} while (0)
+#define UMA_HISTOGRAM_COUNTS_10000(name, sample) do { \
+ static Histogram counter((name), 1, 10000, 50); \
+ counter.SetFlags(kUmaTargetedHistogramFlag); \
+ counter.Add(sample); \
+ } while (0)
+
#define UMA_HISTOGRAM_MEMORY_KB(name, sample) do { \
static Histogram counter((name), 1000, 500000, 50); \
counter.SetFlags(kUmaTargetedHistogramFlag); \
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<int>(use_hours));
-
+ UMA_HISTOGRAM_HOURS("DiskCache.FillupTime", static_cast<int>(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<int>(total_hours));
-
+ UMA_HISTOGRAM_HOURS("DiskCache.TotalTime", static_cast<int>(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<int>(use_hours));
-
+ UMA_HISTOGRAM_HOURS("DiskCache.UseTime", static_cast<int>(use_hours));
UMA_HISTOGRAM_PERCENTAGE("DiskCache.HitRatio", stats_.GetHitRatio());
UMA_HISTOGRAM_PERCENTAGE("DiskCache.ResurrectRatio",
stats_.GetResurrectRatio());
diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc
index 16d0957..0075f5d 100644
--- a/net/disk_cache/eviction.cc
+++ b/net/disk_cache/eviction.cc
@@ -38,6 +38,10 @@
using base::Time;
+// 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 int kCleanUpMargin = 1024 * 1024;
@@ -143,9 +147,8 @@ void Eviction::ReportTrimTimes(EntryImpl* entry) {
if (backend_->ShouldReportAgain()) {
std::string name(StringPrintf("DiskCache.TrimAge_%d",
header_->experiment));
- static Histogram counter(name.c_str(), 1, 10000, 50);
- counter.SetFlags(kUmaTargetedHistogramFlag);
- counter.Add((Time::Now() - entry->GetLastUsed()).InHours());
+ UMA_HISTOGRAM_HOURS(name.c_str(),
+ (Time::Now() - entry->GetLastUsed()).InHours());
}
if (header_->create_time || !header_->lru.filled) {