summaryrefslogtreecommitdiffstats
path: root/base/histogram.h
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-02 06:50:03 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-02 06:50:03 +0000
commitd43e0729bbe1028c64ec29387c5a214e5eaa6dc7 (patch)
tree8c458fa18f2140604a1a241ce858a139b5ed4b7e /base/histogram.h
parent0303f31c7e78cd5e1e54773c50b9216710630cfa (diff)
downloadchromium_src-d43e0729bbe1028c64ec29387c5a214e5eaa6dc7.zip
chromium_src-d43e0729bbe1028c64ec29387c5a214e5eaa6dc7.tar.gz
chromium_src-d43e0729bbe1028c64ec29387c5a214e5eaa6dc7.tar.bz2
Add to SDCH histogramming
Define a histogram macro that is customizable, and precise, for detailed examination of performance when needed. Provide graceful degradation when entire SDCH window is not received. We now blacklist the site with an exponential back-off. This allows teh user to hit reload, and get not-SDCH content. bug=1609306 r=huanr,mbelshe Review URL: http://codereview.chromium.org/19718 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/histogram.h')
-rw-r--r--base/histogram.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/base/histogram.h b/base/histogram.h
index 8b4bded..9860e93 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.
-// These macros all use 50 buckets.
+// The first two macros use 50 buckets.
#define HISTOGRAM_TIMES(name, sample) do { \
static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \
@@ -54,6 +54,13 @@
counter.Add(sample); \
} while (0)
+// For folks that need real specific times, use this, but you'll only get
+// samples that are in the range (overly large samples are discarded).
+#define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \
+ static Histogram counter((name), min, max, bucket_count); \
+ if ((sample) < (max)) counter.AddTime(sample); \
+ } while (0)
+
//------------------------------------------------------------------------------
// This macro set is for a histogram that can support both addition and removal
// of samples. It should be used to render the accumulated asset allocation
@@ -85,12 +92,16 @@
#define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample)
#define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \
sample)
+#define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \
+ HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count)
#else // NDEBUG
#define DHISTOGRAM_TIMES(name, sample) do {} while (0)
#define DHISTOGRAM_COUNTS(name, sample) do {} while (0)
#define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0)
+#define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \
+ do {} while (0)
#endif // NDEBUG
@@ -124,6 +135,12 @@ static const int kUmaTargetedHistogramFlag = 0x1;
counter.AddTime(sample); \
} while (0)
+#define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \
+ static Histogram counter((name), min, max, bucket_count); \
+ counter.SetFlags(kUmaTargetedHistogramFlag); \
+ if ((sample) < (max)) counter.AddTime(sample); \
+ } while (0)
+
#define UMA_HISTOGRAM_COUNTS(name, sample) do { \
static Histogram counter((name), 1, 1000000, 50); \
counter.SetFlags(kUmaTargetedHistogramFlag); \
@@ -176,7 +193,7 @@ class Histogram : public StatsRate {
// Accessor methods.
Count counts(size_t i) const { return counts_[i]; }
- Count TotalCount() const ;
+ Count TotalCount() const;
int64 sum() const { return sum_; }
int64 square_sum() const { return square_sum_; }
@@ -276,7 +293,7 @@ class Histogram : public StatsRate {
// Write a common header message describing this histogram.
void WriteAsciiHeader(const SampleSet& snapshot,
- Count sample_count, std::string* output) const ;
+ Count sample_count, std::string* output) const;
// Write information about previous, current, and next buckets.
// Information such as cumulative percentage, etc.
@@ -375,7 +392,9 @@ class LinearHistogram : public Histogram {
// BooleanHistogram is a histogram for booleans.
class BooleanHistogram : public LinearHistogram {
public:
- BooleanHistogram(const wchar_t* name) : LinearHistogram(name, 0, 2, 3) {}
+ explicit BooleanHistogram(const wchar_t* name)
+ : LinearHistogram(name, 0, 2, 3) {
+ }
virtual void AddBoolean(bool value) { Add(value ? 1 : 0); }