Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) \ |
|
gavinp
2013/01/07 03:59:05
This move makes this part of the code more paralle
| |
| 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, \ |
| 191 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ | 198 base::Histogram::kUmaTargetedHistogramFlag)) |
|
Ilya Sherman
2013/01/07 22:52:23
This should not be UMA-targeted.
gavinp
2013/01/08 17:12:41
No kidding. Fixed.
| |
| 192 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ | |
| 193 base::HistogramBase::kNoFlags)) | |
| 194 | 199 |
| 195 // Support histograming of an enumerated value. The samples should always be | 200 // Support histograming of an enumerated value. The samples should always be |
| 196 // strictly less than |boundary_value| -- this prevents you from running into | 201 // 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 | 202 // 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, | 203 // 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 | 204 // it is fine for enumerated histograms to be 0-indexed -- this is because |
| 200 // enumerated histograms should never have underflow. | 205 // enumerated histograms should never have underflow. |
| 201 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 206 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
| 202 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 207 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 203 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ | 208 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 703 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 699 static BucketRanges* CreateBucketRangesFromCustomRanges( | 704 static BucketRanges* CreateBucketRangesFromCustomRanges( |
| 700 const std::vector<Sample>& custom_ranges); | 705 const std::vector<Sample>& custom_ranges); |
| 701 | 706 |
| 702 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 707 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 703 }; | 708 }; |
| 704 | 709 |
| 705 } // namespace base | 710 } // namespace base |
| 706 | 711 |
| 707 #endif // BASE_METRICS_HISTOGRAM_H_ | 712 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |