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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 #define STATIC_HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \ | 102 #define STATIC_HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \ |
103 histogram_add_method_invocation, \ | 103 histogram_add_method_invocation, \ |
104 histogram_factory_get_invocation) \ | 104 histogram_factory_get_invocation) \ |
105 do { \ | 105 do { \ |
106 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ | 106 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ |
107 HISTOGRAM_POINTER_USE(&atomic_histogram_pointer, constant_histogram_name, \ | 107 HISTOGRAM_POINTER_USE(&atomic_histogram_pointer, constant_histogram_name, \ |
108 histogram_add_method_invocation, \ | 108 histogram_add_method_invocation, \ |
109 histogram_factory_get_invocation); \ | 109 histogram_factory_get_invocation); \ |
110 } while (0) | 110 } while (0) |
111 | 111 |
112 // Support a collection of histograms, perhaps one for each entry in an | |
Alexei Svitkine (slow)
2016/03/30 16:47:38
This seems to be an esoteric use case - and while
bcwhite
2016/03/30 17:33:08
This macro just manages a vector. It knows nothin
Alexei Svitkine (slow)
2016/04/06 19:57:17
Right, but it requires having an index that also c
bcwhite
2016/04/07 16:37:42
Gotcha. Right.
| |
113 // enumeration. This macro manages a block of pointers, adding to a specific | |
114 // one by its index. | |
115 #define STATIC_HISTOGRAM_POINTER_GROUP(constant_histogram_name, index, \ | |
116 constant_maximum, \ | |
117 histogram_add_method_invocation, \ | |
118 histogram_factory_get_invocation) \ | |
119 do { \ | |
120 static base::subtle::AtomicWord atomic_histograms[constant_maximum]; \ | |
121 DCHECK_LE(0, index); \ | |
122 DCHECK_LT(index, constant_maximum); \ | |
123 HISTOGRAM_POINTER_USE(&atomic_histograms[index], constant_histogram_name, \ | |
124 histogram_add_method_invocation, \ | |
125 histogram_factory_get_invocation); \ | |
126 } while (0) | |
127 | |
128 | |
112 //------------------------------------------------------------------------------ | 129 //------------------------------------------------------------------------------ |
113 // Provide easy general purpose histogram in a macro, just like stats counters. | 130 // Provide easy general purpose histogram in a macro, just like stats counters. |
114 // The first four macros use 50 buckets. | 131 // The first four macros use 50 buckets. |
115 | 132 |
116 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ | 133 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ |
117 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 134 name, sample, base::TimeDelta::FromMilliseconds(1), \ |
118 base::TimeDelta::FromSeconds(10), 50) | 135 base::TimeDelta::FromSeconds(10), 50) |
119 | 136 |
120 // For folks that need real specific times, use this to select a precise range | 137 // For folks that need real specific times, use this to select a precise range |
121 // of times you want plotted, and the number of buckets you want used. | 138 // of times you want plotted, and the number of buckets you want used. |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 300 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
284 } else { \ | 301 } else { \ |
285 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 302 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
286 } \ | 303 } \ |
287 } \ | 304 } \ |
288 private: \ | 305 private: \ |
289 base::TimeTicks constructed_; \ | 306 base::TimeTicks constructed_; \ |
290 } scoped_histogram_timer_##key | 307 } scoped_histogram_timer_##key |
291 | 308 |
292 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 309 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |