| 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( \ |
| 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( \ |
| 153 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, \ | 159 name, Add(sample), \ |
| 154 flag)) | 160 base::LinearHistogram::FactoryGet( \ |
| 161 name, 1, boundary, boundary + 1, flag)) |
| 155 | 162 |
| 156 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 163 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 157 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 164 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
| 158 | 165 |
| 159 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ | 166 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ |
| 160 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 167 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
| 161 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) | 168 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) |
| 162 | 169 |
| 163 // Support histograming of an enumerated value. The samples should always be | 170 // Support histograming of an enumerated value. The samples should always be |
| 164 // strictly less than |boundary_value| -- this prevents you from running into | 171 // 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( \ | 229 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 223 name, sample, 1, 100, 50) | 230 name, sample, 1, 100, 50) |
| 224 | 231 |
| 225 #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 232 #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 226 name, sample, 1, 1000, 50) | 233 name, sample, 1, 1000, 50) |
| 227 | 234 |
| 228 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 235 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 229 name, sample, 1, 10000, 50) | 236 name, sample, 1, 10000, 50) |
| 230 | 237 |
| 231 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 238 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 232 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 239 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
| 233 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 240 name, sample, min, max, bucket_count, \ |
| 234 base::HistogramBase::kUmaTargetedHistogramFlag)) | 241 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 242 |
| 243 #define UMA_STABILITY_HISTOGRAM_COUNTS_100(name, sample) \ |
| 244 UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) |
| 245 |
| 246 #define UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, \ |
| 247 bucket_count) \ |
| 248 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
| 249 name, sample, min, max, bucket_count, \ |
| 250 base::HistogramBase::kUmaStabilityHistogramFlag) |
| 235 | 251 |
| 236 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 252 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 237 name, sample, 1000, 500000, 50) | 253 name, sample, 1000, 500000, 50) |
| 238 | 254 |
| 239 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 255 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 240 name, sample, 1, 1000, 50) | 256 name, sample, 1, 1000, 50) |
| 241 | 257 |
| 242 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ | 258 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ |
| 243 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) | 259 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) |
| 244 | 260 |
| 245 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 261 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 246 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 262 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
| 247 | 263 |
| 248 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ | 264 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ |
| 249 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 265 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
| 250 base::BooleanHistogram::FactoryGet(name, \ | 266 base::BooleanHistogram::FactoryGet(name, \ |
| 251 base::HistogramBase::kUmaTargetedHistogramFlag)) | 267 base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 252 | 268 |
| 253 // The samples should always be strictly less than |boundary_value|. For more | 269 // The samples should always be strictly less than |boundary_value|. For more |
| 254 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. | 270 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. |
| 255 #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 271 #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
| 256 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 272 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
| 273 name, sample, boundary_value, \ |
| 257 base::HistogramBase::kUmaTargetedHistogramFlag) | 274 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 258 | 275 |
| 259 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability | 276 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability |
| 260 // histograms. Use this if recording a histogram that should be part of the | 277 // histograms. Use this if recording a histogram that should be part of the |
| 261 // initial stability log. | 278 // initial stability log. |
| 262 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 279 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
| 263 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 280 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
| 281 name, sample, boundary_value, \ |
| 264 base::HistogramBase::kUmaStabilityHistogramFlag) | 282 base::HistogramBase::kUmaStabilityHistogramFlag) |
| 265 | 283 |
| 266 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 284 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
| 267 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 285 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 268 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 286 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
| 269 base::HistogramBase::kUmaTargetedHistogramFlag)) | 287 base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 270 | 288 |
| 271 // Scoped class which logs its time on this earth as a UMA statistic. This is | 289 // 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 | 290 // 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. | 291 // for a method to execute. This measures up to 10 seconds. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 294 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 312 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
| 295 } else { \ | 313 } else { \ |
| 296 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 314 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
| 297 } \ | 315 } \ |
| 298 } \ | 316 } \ |
| 299 private: \ | 317 private: \ |
| 300 base::TimeTicks constructed_; \ | 318 base::TimeTicks constructed_; \ |
| 301 } scoped_histogram_timer_##key | 319 } scoped_histogram_timer_##key |
| 302 | 320 |
| 303 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 321 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
| OLD | NEW |