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

Side by Side Diff: base/histogram.h

Issue 40319: Use filter context to track stats better in SDCH filtering (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/automation/url_request_mock_http_job.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 8
9 // It supports calls to accumulate either time intervals (which are processed 9 // It supports calls to accumulate either time intervals (which are processed
10 // as integral number of milliseconds), or arbitrary integral units. 10 // as integral number of milliseconds), or arbitrary integral units.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #define HISTOGRAM_COUNTS(name, sample) do { \ 53 #define HISTOGRAM_COUNTS(name, sample) do { \
54 static Histogram counter((name), 1, 1000000, 50); \ 54 static Histogram counter((name), 1, 1000000, 50); \
55 counter.Add(sample); \ 55 counter.Add(sample); \
56 } while (0) 56 } while (0)
57 57
58 #define HISTOGRAM_COUNTS_100(name, sample) do { \ 58 #define HISTOGRAM_COUNTS_100(name, sample) do { \
59 static Histogram counter((name), 1, 100, 50); \ 59 static Histogram counter((name), 1, 100, 50); \
60 counter.Add(sample); \ 60 counter.Add(sample); \
61 } while (0) 61 } while (0)
62 62
63 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \
64 static LinearHistogram counter((name), 1, 100, 101); \
65 counter.Add(under_one_hundred); \
66 } while (0)
67
63 // For folks that need real specific times, use this, but you'll only get 68 // For folks that need real specific times, use this, but you'll only get
64 // samples that are in the range (overly large samples are discarded). 69 // samples that are in the range (overly large samples are discarded).
65 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ 70 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \
66 static Histogram counter((name), min, max, bucket_count); \ 71 static Histogram counter((name), min, max, bucket_count); \
67 if ((sample) < (max)) counter.AddTime(sample); \ 72 if ((sample) < (max)) counter.AddTime(sample); \
68 } while (0) 73 } while (0)
69 74
70 //------------------------------------------------------------------------------ 75 //------------------------------------------------------------------------------
71 // This macro set is for a histogram that can support both addition and removal 76 // This macro set is for a histogram that can support both addition and removal
72 // of samples. It should be used to render the accumulated asset allocation 77 // of samples. It should be used to render the accumulated asset allocation
(...skipping 18 matching lines...) Expand all
91 } while (0) 96 } while (0)
92 97
93 //------------------------------------------------------------------------------ 98 //------------------------------------------------------------------------------
94 // Define Debug vs non-debug flavors of macros. 99 // Define Debug vs non-debug flavors of macros.
95 #ifndef NDEBUG 100 #ifndef NDEBUG
96 101
97 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) 102 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample)
98 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) 103 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample)
99 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \ 104 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \
100 sample) 105 sample)
106 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\
107 name, under_one_hundred)
101 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ 108 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \
102 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) 109 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count)
103 110
104 #else // NDEBUG 111 #else // NDEBUG
105 112
106 #define DHISTOGRAM_TIMES(name, sample) do {} while (0) 113 #define DHISTOGRAM_TIMES(name, sample) do {} while (0)
107 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0) 114 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0)
108 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0) 115 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0)
116 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0)
109 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ 117 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \
110 do {} while (0) 118 do {} while (0)
111 119
112 #endif // NDEBUG 120 #endif // NDEBUG
113 121
114 //------------------------------------------------------------------------------ 122 //------------------------------------------------------------------------------
115 // The following macros provide typical usage scenarios for callers that wish 123 // The following macros provide typical usage scenarios for callers that wish
116 // to record histogram data, and have the data submitted/uploaded via UMA. 124 // to record histogram data, and have the data submitted/uploaded via UMA.
117 // Not all systems support such UMA, but if they do, the following macros 125 // Not all systems support such UMA, but if they do, the following macros
118 // should work with the service. 126 // should work with the service.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 counter.SetFlags(kUmaTargetedHistogramFlag); \ 177 counter.SetFlags(kUmaTargetedHistogramFlag); \
170 counter.Add(sample); \ 178 counter.Add(sample); \
171 } while (0) 179 } while (0)
172 180
173 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) do { \ 181 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) do { \
174 static Histogram counter((name), 1, 1000, 50); \ 182 static Histogram counter((name), 1, 1000, 50); \
175 counter.SetFlags(kUmaTargetedHistogramFlag); \ 183 counter.SetFlags(kUmaTargetedHistogramFlag); \
176 counter.Add(sample); \ 184 counter.Add(sample); \
177 } while (0) 185 } while (0)
178 186
187 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \
188 static LinearHistogram counter((name), 1, 100, 101); \
189 counter.SetFlags(kUmaTargetedHistogramFlag); \
190 counter.Add(under_one_hundred); \
191 } while (0)
192
179 //------------------------------------------------------------------------------ 193 //------------------------------------------------------------------------------
180 194
181 class Histogram : public StatsRate { 195 class Histogram : public StatsRate {
182 public: 196 public:
183 typedef int Sample; // Used for samples (and ranges of samples). 197 typedef int Sample; // Used for samples (and ranges of samples).
184 typedef int Count; // Used to count samples in a bucket. 198 typedef int Count; // Used to count samples in a bucket.
185 static const Sample kSampleType_MAX = INT_MAX; 199 static const Sample kSampleType_MAX = INT_MAX;
186 200
187 typedef std::vector<Count> Counts; 201 typedef std::vector<Count> Counts;
188 typedef std::vector<Sample> Ranges; 202 typedef std::vector<Sample> Ranges;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // lock protects access to the above map. 535 // lock protects access to the above map.
522 static Lock* lock_; 536 static Lock* lock_;
523 537
524 // Dump all known histograms to log. 538 // Dump all known histograms to log.
525 static bool dump_on_exit_; 539 static bool dump_on_exit_;
526 540
527 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); 541 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder);
528 }; 542 };
529 543
530 #endif // BASE_HISTOGRAM_H__ 544 #endif // BASE_HISTOGRAM_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/url_request_mock_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698