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/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // initial stability log. | 222 // initial stability log. |
223 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 223 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
224 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 224 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ |
225 base::HistogramBase::kUmaStabilityHistogramFlag) | 225 base::HistogramBase::kUmaStabilityHistogramFlag) |
226 | 226 |
227 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 227 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
228 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 228 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
229 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 229 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
230 base::HistogramBase::kUmaTargetedHistogramFlag)) | 230 base::HistogramBase::kUmaTargetedHistogramFlag)) |
231 | 231 |
| 232 // Scoped class which logs its time on this earth as a UMA statistic. This is |
| 233 // recommended for when you want a histogram which measures the time it takes |
| 234 // for a method to execute. This measures up to 10 seconds. |
| 235 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ |
| 236 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, false, __COUNTER__) |
| 237 |
| 238 // Similar scoped histogram timer, but this uses UMA_HISTOGRAM_LONG_TIMES_100, |
| 239 // which measures up to an hour, and uses 100 buckets. This is more expensive |
| 240 // to store, so only use if this often takes >10 seconds. |
| 241 #define SCOPED_UMA_HISTOGRAM_LONG_TIMER(name) \ |
| 242 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, true, __COUNTER__) |
| 243 |
| 244 // This nested macro is necessary to expand __COUNTER__ to an actual value. |
| 245 #define SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, is_long, key) \ |
| 246 SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, is_long, key) |
| 247 |
| 248 #define SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, is_long, key) \ |
| 249 class ScopedHistogramTimer##key { \ |
| 250 public: \ |
| 251 ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \ |
| 252 ~ScopedHistogramTimer##key() { \ |
| 253 base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \ |
| 254 if (is_long) { \ |
| 255 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
| 256 } else { \ |
| 257 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
| 258 } \ |
| 259 } \ |
| 260 private: \ |
| 261 base::TimeTicks constructed_; \ |
| 262 } scoped_histogram_timer_##key |
| 263 |
232 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 264 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |