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. Must be |
| 233 // a #define macro since UMA macros prevent variables as names. The nested |
| 234 // macro is necessary to expand __COUNTER__ to an actual value. |
| 235 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ |
| 236 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, __COUNTER__) |
| 237 |
| 238 #define SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, key) \ |
| 239 SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, key) |
| 240 |
| 241 #define SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, key) \ |
| 242 class ScopedHistogramTimer##key { \ |
| 243 public: \ |
| 244 ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \ |
| 245 ~ScopedHistogramTimer##key() { \ |
| 246 base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \ |
| 247 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
| 248 } \ |
| 249 private: \ |
| 250 base::TimeTicks constructed_; \ |
| 251 } scoped_histogram_timer_##key |
| 252 |
232 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 253 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |