diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/histogram.cc | 10 | ||||
-rw-r--r-- | base/histogram.h | 15 |
2 files changed, 11 insertions, 14 deletions
diff --git a/base/histogram.cc b/base/histogram.cc index d1568429..687a549 100644 --- a/base/histogram.cc +++ b/base/histogram.cc @@ -25,8 +25,7 @@ const int Histogram::kHexRangePrintingFlag = 0x8000; Histogram::Histogram(const char* name, Sample minimum, Sample maximum, size_t bucket_count) - : StatsRate(name), - histogram_name_(name), + : histogram_name_(name), declared_min_(minimum), declared_max_(maximum), bucket_count_(bucket_count), @@ -39,8 +38,7 @@ Histogram::Histogram(const char* name, Sample minimum, Histogram::Histogram(const char* name, TimeDelta minimum, TimeDelta maximum, size_t bucket_count) - : StatsRate(name), - histogram_name_(name), + : histogram_name_(name), declared_min_(static_cast<int> (minimum.InMilliseconds())), declared_max_(static_cast<int> (maximum.InMilliseconds())), bucket_count_(bucket_count), @@ -58,14 +56,11 @@ Histogram::~Histogram() { DCHECK(ValidateBucketRanges()); } -// Hooks to override stats counter methods. This ensures that we gather all -// input the stats counter sees. void Histogram::Add(int value) { if (!registered_) registered_ = StatisticsRecorder::Register(this); if (value >= kSampleType_MAX) value = kSampleType_MAX - 1; - StatsRate::Add(value); if (value < 0) value = 0; size_t index = BucketIndex(value); @@ -631,7 +626,6 @@ ThreadSafeHistogram::ThreadSafeHistogram(const char* name, Sample minimum, void ThreadSafeHistogram::Remove(int value) { if (value >= kSampleType_MAX) value = kSampleType_MAX - 1; - StatsRate::Add(-value); size_t index = BucketIndex(value); Accumulate(value, -1, index); } diff --git a/base/histogram.h b/base/histogram.h index 0773a7a..59981ea 100644 --- a/base/histogram.h +++ b/base/histogram.h @@ -36,7 +36,7 @@ #include <vector> #include "base/lock.h" -#include "base/stats_counters.h" +#include "base/time.h" //------------------------------------------------------------------------------ // Provide easy general purpose histogram in a macro, just like stats counters. @@ -203,7 +203,7 @@ static const int kRendererHistogramFlag = 1 << 4; class Pickle; -class Histogram : public StatsRate { +class Histogram { public: typedef int Sample; // Used for samples (and ranges of samples). typedef int Count; // Used to count samples in a bucket. @@ -263,9 +263,11 @@ class Histogram : public StatsRate { base::TimeDelta maximum, size_t bucket_count); virtual ~Histogram(); - // Hooks to override stats counter methods. This ensures that we gather all - // input the stats counter sees. - virtual void Add(int value); + void Add(int value); + // Accept a TimeDelta to increment. + void AddTime(base::TimeDelta time) { + Add(static_cast<int>(time.InMilliseconds())); + } void AddSampleSet(const SampleSet& sample); @@ -465,7 +467,7 @@ class BooleanHistogram : public LinearHistogram { : LinearHistogram(name, 0, 2, 3) { } - virtual void AddBoolean(bool value) { Add(value ? 1 : 0); } + void AddBoolean(bool value) { Add(value ? 1 : 0); } private: DISALLOW_COPY_AND_ASSIGN(BooleanHistogram); @@ -526,6 +528,7 @@ class StatisticsRecorder { // Method for extracting histograms which were marked for use by UMA. static void GetHistograms(Histograms* output); + // Find a histogram by name. This method is thread safe. static Histogram* GetHistogram(const std::string& query); static void set_dump_on_exit(bool enable) { dump_on_exit_ = enable; } |