OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ |
6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ | 6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \ | 139 #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \ |
140 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) | 140 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) |
141 | 141 |
142 #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 142 #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
143 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 143 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
144 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 144 base::Histogram::FactoryGet(name, min, max, bucket_count, \ |
145 base::HistogramBase::kNoFlags)) | 145 base::HistogramBase::kNoFlags)) |
146 | 146 |
147 // This is a helper macro used by other macros and shouldn't be used directly. | 147 // This is a helper macro used by other macros and shouldn't be used directly. |
| 148 // One additional bucket is created in the LinearHistogram for the illegal |
| 149 // values >= boundary_value so that mistakes in calling the UMA enumeration |
| 150 // macros can be detected. |
148 #define HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ | 151 #define HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ |
149 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 152 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
150 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, \ | 153 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, \ |
151 flag)) | 154 flag)) |
152 | 155 |
153 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 156 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
154 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 157 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
155 | 158 |
156 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ | 159 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ |
157 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 160 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
158 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) | 161 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) |
159 | 162 |
160 // Support histograming of an enumerated value. The samples should always be | 163 // Support histograming of an enumerated value. The samples should always be |
161 // strictly less than |boundary_value| -- this prevents you from running into | 164 // strictly less than |boundary_value| -- this prevents you from running into |
162 // problems down the line if you add additional buckets to the histogram. Note | 165 // problems down the line if you add additional buckets to the histogram. Note |
163 // also that, despite explicitly setting the minimum bucket value to |1| below, | 166 // also that, despite explicitly setting the minimum bucket value to |1| below, |
164 // it is fine for enumerated histograms to be 0-indexed -- this is because | 167 // it is fine for enumerated histograms to be 0-indexed -- this is because |
165 // enumerated histograms should never have underflow. | 168 // enumerated histograms should never have underflow. One additional bucket is |
| 169 // created in the LinearHistogram for the illegal values >= boundary_value so |
| 170 // that mistakes in calling this macro can be detected. |
166 #define LOCAL_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 171 #define LOCAL_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
167 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 172 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
168 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ | 173 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ |
169 boundary_value + 1, base::HistogramBase::kNoFlags)) | 174 boundary_value + 1, base::HistogramBase::kNoFlags)) |
170 | 175 |
171 // Support histograming of an enumerated value. Samples should be one of the | 176 // Support histograming of an enumerated value. Samples should be one of the |
172 // std::vector<int> list provided via |custom_ranges|. See comments above | 177 // std::vector<int> list provided via |custom_ranges|. See comments above |
173 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. | 178 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. |
174 // You can use the helper function CustomHistogram::ArrayToCustomRanges to | 179 // You can use the helper function CustomHistogram::ArrayToCustomRanges to |
175 // transform a C-style array of valid sample values to a std::vector<int>. | 180 // transform a C-style array of valid sample values to a std::vector<int>. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 294 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
290 } else { \ | 295 } else { \ |
291 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 296 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
292 } \ | 297 } \ |
293 } \ | 298 } \ |
294 private: \ | 299 private: \ |
295 base::TimeTicks constructed_; \ | 300 base::TimeTicks constructed_; \ |
296 } scoped_histogram_timer_##key | 301 } scoped_histogram_timer_##key |
297 | 302 |
298 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 303 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |