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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 #define LOCAL_HISTOGRAM_COUNTS(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \ | 133 #define LOCAL_HISTOGRAM_COUNTS(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \ |
134 name, sample, 1, 1000000, 50) | 134 name, sample, 1, 1000000, 50) |
135 | 135 |
136 #define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \ | 136 #define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \ |
137 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) | 137 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) |
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 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
Alexei Svitkine (slow)
2016/09/08 21:00:41
Nit: Your indents seem off. Should be indented 4 a
manzagop (departed)
2016/09/08 21:22:24
'git cl format' is what gives the 2 space indent..
| |
144 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 144 name, sample, min, max, bucket_count, base::HistogramBase::kNoFlags) |
145 base::HistogramBase::kNoFlags)) | 145 |
146 // This is a helper macro used by other macros and shouldn't be used directly. | |
147 #define INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG(name, sample, min, max, \ | |
148 bucket_count, flag) \ | |
149 STATIC_HISTOGRAM_POINTER_BLOCK( \ | |
150 name, Add(sample), \ | |
151 base::Histogram::FactoryGet(name, min, max, bucket_count, flag)) | |
146 | 152 |
147 // This is a helper macro used by other macros and shouldn't be used directly. | 153 // 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 | 154 // One additional bucket is created in the LinearHistogram for the illegal |
149 // values >= boundary_value so that mistakes in calling the UMA enumeration | 155 // values >= boundary_value so that mistakes in calling the UMA enumeration |
150 // macros can be detected. | 156 // macros can be detected. |
151 #define HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ | 157 #define INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ |
152 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 158 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
153 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, \ | 159 base::LinearHistogram::FactoryGet( \ |
154 flag)) | 160 name, 1, boundary, boundary + 1, flag)) |
155 | 161 |
156 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 162 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
157 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 163 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
158 | 164 |
159 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ | 165 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ |
160 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 166 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
161 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) | 167 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) |
162 | 168 |
163 // Support histograming of an enumerated value. The samples should always be | 169 // Support histograming of an enumerated value. The samples should always be |
164 // strictly less than |boundary_value| -- this prevents you from running into | 170 // strictly less than |boundary_value| -- this prevents you from running into |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 228 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
223 name, sample, 1, 100, 50) | 229 name, sample, 1, 100, 50) |
224 | 230 |
225 #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 231 #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
226 name, sample, 1, 1000, 50) | 232 name, sample, 1, 1000, 50) |
227 | 233 |
228 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 234 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
229 name, sample, 1, 10000, 50) | 235 name, sample, 1, 10000, 50) |
230 | 236 |
231 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 237 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
232 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 238 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
233 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 239 name, sample, min, max, bucket_count, \ |
234 base::HistogramBase::kUmaTargetedHistogramFlag)) | 240 base::HistogramBase::kUmaTargetedHistogramFlag) |
241 | |
242 #define UMA_STABILITY_HISTOGRAM_COUNTS_100(name, sample) \ | |
243 UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) | |
244 | |
245 #define UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, \ | |
246 bucket_count) \ | |
247 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ | |
248 name, sample, min, max, bucket_count, \ | |
249 base::HistogramBase::kUmaStabilityHistogramFlag) | |
235 | 250 |
236 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 251 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
237 name, sample, 1000, 500000, 50) | 252 name, sample, 1000, 500000, 50) |
238 | 253 |
239 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 254 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
240 name, sample, 1, 1000, 50) | 255 name, sample, 1, 1000, 50) |
241 | 256 |
242 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ | 257 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ |
243 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) | 258 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) |
244 | 259 |
245 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 260 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
246 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 261 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
247 | 262 |
248 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ | 263 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ |
249 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 264 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
250 base::BooleanHistogram::FactoryGet(name, \ | 265 base::BooleanHistogram::FactoryGet(name, \ |
251 base::HistogramBase::kUmaTargetedHistogramFlag)) | 266 base::HistogramBase::kUmaTargetedHistogramFlag)) |
252 | 267 |
253 // The samples should always be strictly less than |boundary_value|. For more | 268 // The samples should always be strictly less than |boundary_value|. For more |
254 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. | 269 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. |
255 #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 270 #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
256 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 271 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
257 base::HistogramBase::kUmaTargetedHistogramFlag) | 272 name, sample, boundary_value, \ |
273 base::HistogramBase::kUmaTargetedHistogramFlag) | |
258 | 274 |
259 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability | 275 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability |
260 // histograms. Use this if recording a histogram that should be part of the | 276 // histograms. Use this if recording a histogram that should be part of the |
261 // initial stability log. | 277 // initial stability log. |
262 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 278 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
263 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 279 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
264 base::HistogramBase::kUmaStabilityHistogramFlag) | 280 name, sample, boundary_value, \ |
281 base::HistogramBase::kUmaStabilityHistogramFlag) | |
265 | 282 |
266 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 283 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
267 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 284 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
268 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 285 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
269 base::HistogramBase::kUmaTargetedHistogramFlag)) | 286 base::HistogramBase::kUmaTargetedHistogramFlag)) |
270 | 287 |
271 // Scoped class which logs its time on this earth as a UMA statistic. This is | 288 // Scoped class which logs its time on this earth as a UMA statistic. This is |
272 // recommended for when you want a histogram which measures the time it takes | 289 // recommended for when you want a histogram which measures the time it takes |
273 // for a method to execute. This measures up to 10 seconds. | 290 // for a method to execute. This measures up to 10 seconds. |
274 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ | 291 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ |
(...skipping 19 matching lines...) Expand all Loading... | |
294 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 311 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
295 } else { \ | 312 } else { \ |
296 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 313 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
297 } \ | 314 } \ |
298 } \ | 315 } \ |
299 private: \ | 316 private: \ |
300 base::TimeTicks constructed_; \ | 317 base::TimeTicks constructed_; \ |
301 } scoped_histogram_timer_##key | 318 } scoped_histogram_timer_##key |
302 | 319 |
303 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 320 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |