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

Side by Side Diff: base/metrics/histogram.h

Issue 11794020: Incrementally make base histograms like UMA histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: guh Created 7 years, 11 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 | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 162
163 //------------------------------------------------------------------------------ 163 //------------------------------------------------------------------------------
164 // Provide easy general purpose histogram in a macro, just like stats counters. 164 // Provide easy general purpose histogram in a macro, just like stats counters.
165 // The first four macros use 50 buckets. 165 // The first four macros use 50 buckets.
166 166
167 #define HISTOGRAM_TIMES(name, sample) HISTOGRAM_CUSTOM_TIMES( \ 167 #define HISTOGRAM_TIMES(name, sample) HISTOGRAM_CUSTOM_TIMES( \
168 name, sample, base::TimeDelta::FromMilliseconds(1), \ 168 name, sample, base::TimeDelta::FromMilliseconds(1), \
169 base::TimeDelta::FromSeconds(10), 50) 169 base::TimeDelta::FromSeconds(10), 50)
170 170
171 // For folks that need real specific times, use this to select a precise range
172 // of times you want plotted, and the number of buckets you want used.
173 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
174 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \
175 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \
176 base::HistogramBase::kNoFlags))
177
171 #define HISTOGRAM_COUNTS(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ 178 #define HISTOGRAM_COUNTS(name, sample) HISTOGRAM_CUSTOM_COUNTS( \
172 name, sample, 1, 1000000, 50) 179 name, sample, 1, 1000000, 50)
173 180
174 #define HISTOGRAM_COUNTS_100(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ 181 #define HISTOGRAM_COUNTS_100(name, sample) HISTOGRAM_CUSTOM_COUNTS( \
175 name, sample, 1, 100, 50) 182 name, sample, 1, 100, 50)
176 183
177 #define HISTOGRAM_COUNTS_10000(name, sample) HISTOGRAM_CUSTOM_COUNTS( \ 184 #define HISTOGRAM_COUNTS_10000(name, sample) HISTOGRAM_CUSTOM_COUNTS( \
178 name, sample, 1, 10000, 50) 185 name, sample, 1, 10000, 50)
179 186
180 #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ 187 #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \
181 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ 188 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
182 base::Histogram::FactoryGet(name, min, max, bucket_count, \ 189 base::Histogram::FactoryGet(name, min, max, bucket_count, \
183 base::HistogramBase::kNoFlags)) 190 base::HistogramBase::kNoFlags))
184 191
185 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ 192 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \
186 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) 193 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101)
187 194
188 // For folks that need real specific times, use this to select a precise range 195 #define HISTOGRAM_BOOLEAN(name, sample) \
189 // of times you want plotted, and the number of buckets you want used. 196 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \
190 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ 197 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags))
191 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \
192 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \
193 base::HistogramBase::kNoFlags))
194 198
195 // Support histograming of an enumerated value. The samples should always be 199 // Support histograming of an enumerated value. The samples should always be
196 // strictly less than |boundary_value| -- this prevents you from running into 200 // strictly less than |boundary_value| -- this prevents you from running into
197 // problems down the line if you add additional buckets to the histogram. Note 201 // problems down the line if you add additional buckets to the histogram. Note
198 // also that, despite explicitly setting the minimum bucket value to |1| below, 202 // also that, despite explicitly setting the minimum bucket value to |1| below,
199 // it is fine for enumerated histograms to be 0-indexed -- this is because 203 // it is fine for enumerated histograms to be 0-indexed -- this is because
200 // enumerated histograms should never have underflow. 204 // enumerated histograms should never have underflow.
201 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ 205 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \
202 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ 206 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
203 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ 207 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); 702 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges);
699 static BucketRanges* CreateBucketRangesFromCustomRanges( 703 static BucketRanges* CreateBucketRangesFromCustomRanges(
700 const std::vector<Sample>& custom_ranges); 704 const std::vector<Sample>& custom_ranges);
701 705
702 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); 706 DISALLOW_COPY_AND_ASSIGN(CustomHistogram);
703 }; 707 };
704 708
705 } // namespace base 709 } // namespace base
706 710
707 #endif // BASE_METRICS_HISTOGRAM_H_ 711 #endif // BASE_METRICS_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698