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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 //------------------------------------------------------------------------------ | 112 //------------------------------------------------------------------------------ |
113 // Provide easy general purpose histogram in a macro, just like stats counters. | 113 // Provide easy general purpose histogram in a macro, just like stats counters. |
114 // The first four macros use 50 buckets. | 114 // Most of these macros use 50 buckets, but check the definition for details. |
115 // | |
116 // All of these macros must be called with |constant_name| as a compile-time | |
Ilya Sherman
2016/02/24 06:47:02
s/compile-time/runtime
Matt Giuca
2016/04/08 01:23:16
Done.
| |
117 // constant. Otherwise, the above optimization will DCHECK, and failing that, | |
118 // will result in data being written to the wrong histogram. | |
115 | 119 |
116 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ | 120 #define LOCAL_HISTOGRAM_TIMES(constant_name, sample) \ |
Ilya Sherman
2016/02/24 06:47:02
I'm not sure that constant_name is clearer here --
Matt Giuca
2016/02/24 07:22:14
True. I debated whether to send this at all becaus
Matt Giuca
2016/04/08 01:23:16
Done.
| |
117 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 121 LOCAL_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, \ |
118 base::TimeDelta::FromSeconds(10), 50) | 122 base::TimeDelta::FromMilliseconds(1), \ |
123 base::TimeDelta::FromSeconds(10), 50) | |
119 | 124 |
120 // For folks that need real specific times, use this to select a precise range | 125 // 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. | 126 // of times you want plotted, and the number of buckets you want used. |
122 #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 127 #define LOCAL_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, min, max, \ |
123 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ | 128 bucket_count) \ |
124 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ | 129 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
125 base::HistogramBase::kNoFlags)) | 130 constant_name, AddTime(sample), \ |
131 base::Histogram::FactoryTimeGet(constant_name, min, max, bucket_count, \ | |
132 base::HistogramBase::kNoFlags)) | |
126 | 133 |
127 #define LOCAL_HISTOGRAM_COUNTS(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \ | 134 #define LOCAL_HISTOGRAM_COUNTS(constant_name, sample) \ |
128 name, sample, 1, 1000000, 50) | 135 LOCAL_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 1000000, 50) |
129 | 136 |
130 #define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \ | 137 #define LOCAL_HISTOGRAM_COUNTS_100(constant_name, sample) \ |
131 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) | 138 LOCAL_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 100, 50) |
132 | 139 |
133 #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \ | 140 #define LOCAL_HISTOGRAM_COUNTS_10000(constant_name, sample) \ |
134 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) | 141 LOCAL_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 10000, 50) |
135 | 142 |
136 #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 143 #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, min, max, \ |
137 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 144 bucket_count) \ |
138 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 145 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
139 base::HistogramBase::kNoFlags)) | 146 constant_name, Add(sample), \ |
147 base::Histogram::FactoryGet(constant_name, min, max, bucket_count, \ | |
148 base::HistogramBase::kNoFlags)) | |
140 | 149 |
141 // This is a helper macro used by other macros and shouldn't be used directly. | 150 // This is a helper macro used by other macros and shouldn't be used directly. |
142 #define HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary, flag) \ | 151 #define HISTOGRAM_ENUMERATION_WITH_FLAG(constant_name, sample, boundary, flag) \ |
143 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 152 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
144 base::LinearHistogram::FactoryGet(name, 1, boundary, boundary + 1, \ | 153 constant_name, Add(sample), \ |
145 flag)) | 154 base::LinearHistogram::FactoryGet(constant_name, 1, boundary, \ |
155 boundary + 1, flag)) | |
146 | 156 |
147 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 157 #define LOCAL_HISTOGRAM_PERCENTAGE(constant_name, under_one_hundred) \ |
148 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 158 LOCAL_HISTOGRAM_ENUMERATION(constant_name, under_one_hundred, 101) |
149 | 159 |
150 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ | 160 #define LOCAL_HISTOGRAM_BOOLEAN(constant_name, sample) \ |
151 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 161 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
152 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) | 162 constant_name, AddBoolean(sample), \ |
163 base::BooleanHistogram::FactoryGet(constant_name, \ | |
164 base::Histogram::kNoFlags)) | |
153 | 165 |
154 // Support histograming of an enumerated value. The samples should always be | 166 // Support histograming of an enumerated value. The samples should always be |
155 // strictly less than |boundary_value| -- this prevents you from running into | 167 // strictly less than |boundary_value| -- this prevents you from running into |
156 // problems down the line if you add additional buckets to the histogram. Note | 168 // problems down the line if you add additional buckets to the histogram. Note |
157 // also that, despite explicitly setting the minimum bucket value to |1| below, | 169 // also that, despite explicitly setting the minimum bucket value to |1| below, |
158 // it is fine for enumerated histograms to be 0-indexed -- this is because | 170 // it is fine for enumerated histograms to be 0-indexed -- this is because |
159 // enumerated histograms should never have underflow. | 171 // enumerated histograms should never have underflow. |
160 #define LOCAL_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 172 #define LOCAL_HISTOGRAM_ENUMERATION(constant_name, sample, boundary_value) \ |
161 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 173 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
162 base::LinearHistogram::FactoryGet(name, 1, boundary_value, \ | 174 constant_name, Add(sample), \ |
163 boundary_value + 1, base::HistogramBase::kNoFlags)) | 175 base::LinearHistogram::FactoryGet(constant_name, 1, boundary_value, \ |
176 boundary_value + 1, \ | |
177 base::HistogramBase::kNoFlags)) | |
164 | 178 |
165 // Support histograming of an enumerated value. Samples should be one of the | 179 // Support histograming of an enumerated value. Samples should be one of the |
166 // std::vector<int> list provided via |custom_ranges|. See comments above | 180 // std::vector<int> list provided via |custom_ranges|. See comments above |
167 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. | 181 // CustomRanges::FactoryGet about the requirement of |custom_ranges|. |
168 // You can use the helper function CustomHistogram::ArrayToCustomRanges to | 182 // You can use the helper function CustomHistogram::ArrayToCustomRanges to |
169 // transform a C-style array of valid sample values to a std::vector<int>. | 183 // transform a C-style array of valid sample values to a std::vector<int>. |
170 #define LOCAL_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 184 #define LOCAL_HISTOGRAM_CUSTOM_ENUMERATION(constant_name, sample, \ |
171 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 185 custom_ranges) \ |
172 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 186 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
173 base::HistogramBase::kNoFlags)) | 187 constant_name, Add(sample), \ |
188 base::CustomHistogram::FactoryGet(constant_name, custom_ranges, \ | |
189 base::HistogramBase::kNoFlags)) | |
174 | 190 |
175 #define LOCAL_HISTOGRAM_MEMORY_KB(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \ | 191 #define LOCAL_HISTOGRAM_MEMORY_KB(constant_name, sample) \ |
176 name, sample, 1000, 500000, 50) | 192 LOCAL_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1000, 500000, 50) |
177 | 193 |
178 //------------------------------------------------------------------------------ | 194 //------------------------------------------------------------------------------ |
179 // The following macros provide typical usage scenarios for callers that wish | 195 // The following macros provide typical usage scenarios for callers that wish |
180 // to record histogram data, and have the data submitted/uploaded via UMA. | 196 // to record histogram data, and have the data submitted/uploaded via UMA. |
181 // Not all systems support such UMA, but if they do, the following macros | 197 // Not all systems support such UMA, but if they do, the following macros |
182 // should work with the service. | 198 // should work with the service. |
183 | 199 |
184 #define UMA_HISTOGRAM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 200 #define UMA_HISTOGRAM_TIMES(constant_name, sample) \ |
185 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 201 UMA_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, \ |
186 base::TimeDelta::FromSeconds(10), 50) | 202 base::TimeDelta::FromMilliseconds(1), \ |
203 base::TimeDelta::FromSeconds(10), 50) | |
187 | 204 |
188 #define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 205 #define UMA_HISTOGRAM_MEDIUM_TIMES(constant_name, sample) \ |
189 name, sample, base::TimeDelta::FromMilliseconds(10), \ | 206 UMA_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, \ |
190 base::TimeDelta::FromMinutes(3), 50) | 207 base::TimeDelta::FromMilliseconds(10), \ |
208 base::TimeDelta::FromMinutes(3), 50) | |
191 | 209 |
192 // Use this macro when times can routinely be much longer than 10 seconds. | 210 // Use this macro when times can routinely be much longer than 10 seconds. |
193 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 211 #define UMA_HISTOGRAM_LONG_TIMES(constant_name, sample) \ |
194 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 212 UMA_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, \ |
195 base::TimeDelta::FromHours(1), 50) | 213 base::TimeDelta::FromMilliseconds(1), \ |
214 base::TimeDelta::FromHours(1), 50) | |
196 | 215 |
197 // Use this macro when times can routinely be much longer than 10 seconds and | 216 // Use this macro when times can routinely be much longer than 10 seconds and |
198 // you want 100 buckets. | 217 // you want 100 buckets. |
199 #define UMA_HISTOGRAM_LONG_TIMES_100(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 218 #define UMA_HISTOGRAM_LONG_TIMES_100(constant_name, sample) \ |
200 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 219 UMA_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, \ |
201 base::TimeDelta::FromHours(1), 100) | 220 base::TimeDelta::FromMilliseconds(1), \ |
221 base::TimeDelta::FromHours(1), 100) | |
202 | 222 |
203 #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 223 #define UMA_HISTOGRAM_CUSTOM_TIMES(constant_name, sample, min, max, \ |
204 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ | 224 bucket_count) \ |
205 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ | 225 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
206 base::HistogramBase::kUmaTargetedHistogramFlag)) | 226 constant_name, AddTime(sample), \ |
227 base::Histogram::FactoryTimeGet( \ | |
228 constant_name, min, max, bucket_count, \ | |
229 base::HistogramBase::kUmaTargetedHistogramFlag)) | |
207 | 230 |
208 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 231 #define UMA_HISTOGRAM_COUNTS(constant_name, sample) \ |
209 name, sample, 1, 1000000, 50) | 232 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 1000000, 50) |
210 | 233 |
211 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 234 #define UMA_HISTOGRAM_COUNTS_100(constant_name, sample) \ |
212 name, sample, 1, 100, 50) | 235 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 100, 50) |
213 | 236 |
214 #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 237 #define UMA_HISTOGRAM_COUNTS_1000(constant_name, sample) \ |
215 name, sample, 1, 1000, 50) | 238 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 1000, 50) |
216 | 239 |
217 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 240 #define UMA_HISTOGRAM_COUNTS_10000(constant_name, sample) \ |
218 name, sample, 1, 10000, 50) | 241 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 10000, 50) |
219 | 242 |
220 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 243 #define UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, min, max, \ |
221 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 244 bucket_count) \ |
222 base::Histogram::FactoryGet(name, min, max, bucket_count, \ | 245 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
223 base::HistogramBase::kUmaTargetedHistogramFlag)) | 246 constant_name, Add(sample), \ |
247 base::Histogram::FactoryGet( \ | |
248 constant_name, min, max, bucket_count, \ | |
249 base::HistogramBase::kUmaTargetedHistogramFlag)) | |
224 | 250 |
225 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 251 #define UMA_HISTOGRAM_MEMORY_KB(constant_name, sample) \ |
226 name, sample, 1000, 500000, 50) | 252 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1000, 500000, 50) |
227 | 253 |
228 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 254 #define UMA_HISTOGRAM_MEMORY_MB(constant_name, sample) \ |
229 name, sample, 1, 1000, 50) | 255 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 1000, 50) |
230 | 256 |
231 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ | 257 #define UMA_HISTOGRAM_MEMORY_LARGE_MB(constant_name, sample) \ |
232 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) | 258 UMA_HISTOGRAM_CUSTOM_COUNTS(constant_name, sample, 1, 64000, 100) |
233 | 259 |
234 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 260 #define UMA_HISTOGRAM_PERCENTAGE(constant_name, under_one_hundred) \ |
235 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 261 UMA_HISTOGRAM_ENUMERATION(constant_name, under_one_hundred, 101) |
236 | 262 |
237 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ | 263 #define UMA_HISTOGRAM_BOOLEAN(constant_name, sample) \ |
238 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 264 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
239 base::BooleanHistogram::FactoryGet(name, \ | 265 constant_name, AddBoolean(sample), \ |
240 base::HistogramBase::kUmaTargetedHistogramFlag)) | 266 base::BooleanHistogram::FactoryGet( \ |
267 constant_name, base::HistogramBase::kUmaTargetedHistogramFlag)) | |
241 | 268 |
242 // 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 |
243 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. | 270 // details, see the comment for the |LOCAL_HISTOGRAM_ENUMERATION| macro, above. |
244 #define UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 271 #define UMA_HISTOGRAM_ENUMERATION(constant_name, sample, boundary_value) \ |
245 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 272 HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
246 base::HistogramBase::kUmaTargetedHistogramFlag) | 273 constant_name, sample, boundary_value, \ |
274 base::HistogramBase::kUmaTargetedHistogramFlag) | |
247 | 275 |
248 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability | 276 // Similar to UMA_HISTOGRAM_ENUMERATION, but used for recording stability |
249 // 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 |
250 // initial stability log. | 278 // initial stability log. |
251 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 279 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(constant_name, sample, \ |
252 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 280 boundary_value) \ |
253 base::HistogramBase::kUmaStabilityHistogramFlag) | 281 HISTOGRAM_ENUMERATION_WITH_FLAG( \ |
282 constant_name, sample, boundary_value, \ | |
283 base::HistogramBase::kUmaStabilityHistogramFlag) | |
254 | 284 |
255 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 285 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(constant_name, sample, custom_ranges) \ |
256 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 286 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
257 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 287 constant_name, Add(sample), \ |
258 base::HistogramBase::kUmaTargetedHistogramFlag)) | 288 base::CustomHistogram::FactoryGet( \ |
289 constant_name, custom_ranges, \ | |
290 base::HistogramBase::kUmaTargetedHistogramFlag)) | |
259 | 291 |
260 // Scoped class which logs its time on this earth as a UMA statistic. This is | 292 // Scoped class which logs its time on this earth as a UMA statistic. This is |
261 // recommended for when you want a histogram which measures the time it takes | 293 // recommended for when you want a histogram which measures the time it takes |
262 // for a method to execute. This measures up to 10 seconds. | 294 // for a method to execute. This measures up to 10 seconds. |
263 #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ | 295 #define SCOPED_UMA_HISTOGRAM_TIMER(constant_name) \ |
264 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, false, __COUNTER__) | 296 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(constant_name, false, __COUNTER__) |
265 | 297 |
266 // Similar scoped histogram timer, but this uses UMA_HISTOGRAM_LONG_TIMES_100, | 298 // Similar scoped histogram timer, but this uses UMA_HISTOGRAM_LONG_TIMES_100, |
267 // which measures up to an hour, and uses 100 buckets. This is more expensive | 299 // which measures up to an hour, and uses 100 buckets. This is more expensive |
268 // to store, so only use if this often takes >10 seconds. | 300 // to store, so only use if this often takes >10 seconds. |
269 #define SCOPED_UMA_HISTOGRAM_LONG_TIMER(name) \ | 301 #define SCOPED_UMA_HISTOGRAM_LONG_TIMER(constant_name) \ |
270 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, true, __COUNTER__) | 302 SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(constant_name, true, __COUNTER__) |
271 | 303 |
272 // This nested macro is necessary to expand __COUNTER__ to an actual value. | 304 // This nested macro is necessary to expand __COUNTER__ to an actual value. |
273 #define SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, is_long, key) \ | 305 #define SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(constant_name, is_long, key) \ |
274 SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, is_long, key) | 306 SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(constant_name, is_long, key) |
275 | 307 |
276 #define SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(name, is_long, key) \ | 308 #define SCOPED_UMA_HISTOGRAM_TIMER_UNIQUE(constant_name, is_long, key) \ |
277 class ScopedHistogramTimer##key { \ | 309 class ScopedHistogramTimer##key { \ |
278 public: \ | 310 public: \ |
279 ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \ | 311 ScopedHistogramTimer##key() : constructed_(base::TimeTicks::Now()) {} \ |
280 ~ScopedHistogramTimer##key() { \ | 312 ~ScopedHistogramTimer##key() { \ |
281 base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \ | 313 base::TimeDelta elapsed = base::TimeTicks::Now() - constructed_; \ |
282 if (is_long) { \ | 314 if (is_long) { \ |
283 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 315 UMA_HISTOGRAM_LONG_TIMES_100(constant_name, elapsed); \ |
284 } else { \ | 316 } else { \ |
285 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 317 UMA_HISTOGRAM_TIMES(constant_name, elapsed); \ |
286 } \ | 318 } \ |
287 } \ | 319 } \ |
288 private: \ | 320 private: \ |
289 base::TimeTicks constructed_; \ | 321 base::TimeTicks constructed_; \ |
290 } scoped_histogram_timer_##key | 322 } scoped_histogram_timer_##key |
291 | 323 |
292 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 324 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |