| 6 | #define BASE_METRICS_HISTOGRAM_MACROS_H_ |
| 7 |
| 8 | #include "base/macros.h" |
| 9 | #include "base/metrics/histogram.h" |
| 10 | #include "base/metrics/histogram_macros_internal.h" |
| 11 | #include "base/metrics/histogram_macros_local.h" |
| 12 | #include "base/time/time.h" |
| 13 |
| 14 |
| 15 | // Macros for efficient use of histograms. |
| 16 | // |
| 17 | // For best practices on deciding when to emit to a histogram and what form |
| 18 | // the histogram should take, see |
| 19 | // https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md |
| 20 |
| 21 | // All of these macros must be called with |name| as a runtime constant - it |
| 22 | // doesn't have to literally be a constant, but it must be the same string on |
| 23 | // all calls from a particular call site. If this rule is violated, it is |
| 24 | // possible the data will be written to the wrong histogram. |
| 25 |
| 26 | //------------------------------------------------------------------------------ |
| 27 | // Enumeration histograms. |
| 28 |
| 29 | // These macros create histograms for enumerated data. Ideally, the data should |
| 30 | // be of the form of "event occurs, log the result". We recommended not putting |
| 31 | // related but not directly connected data as enums within the same histogram. |
| 32 | // You should be defining an associated Enum, and the input sample should be |
| 33 | // an element of the Enum. |
| 34 | // All of these macros must be called with |name| as a runtime constant. |
| 35 |
| 36 | // The first variant of UMA_HISTOGRAM_ENUMERATION accepts two arguments: the |
| 37 | // histogram name and the enum sample. It deduces the correct boundary value to |
| 38 | // use by looking for an enumerator with the name kMaxValue. kMaxValue should |
| 39 | // share the value of the highest enumerator: this avoids switch statements |
| 40 | // having to handle a sentinel no-op value. |
| 41 | // |
| 42 | // Sample usage: |
| 43 | // // These values are logged to UMA. Entries should not be renumbered and |
| 44 | // // numeric values should never be reused. Please keep in sync with "MyEnum" |
| 45 | // // in src/tools/metrics/histograms/enums.xml. |
| 46 | // enum class MyEnum { |
| 47 | // kFirstValue = 0, |
| 48 | // kSecondValue = 1, |
| 49 | // ... |
| 50 | // kFinalValue = N, |
| 51 | // kMaxValue = kFinalValue, |
| 52 | // }; |
| 53 | // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", MyEnum::kSomeValue); |
| 54 | // |
| 55 | // The second variant requires three arguments: the first two are the same as |
| 56 | // before, and the third argument is the enum boundary: this must be strictly |
| 57 | // greater than any other enumerator that will be sampled. |
| 58 | // |
| 59 | // Sample usage: |
| 60 | // // These values are logged to UMA. Entries should not be renumbered and |
| 61 | // // numeric values should never be reused. Please keep in sync with "MyEnum" |
| 62 | // // in src/tools/metrics/histograms/enums.xml. |
| 63 | // enum class MyEnum { |
| 64 | // FIRST_VALUE = 0, |
| 65 | // SECOND_VALUE = 1, |
| 66 | // ... |
| 67 | // FINAL_VALUE = N, |
| 68 | // COUNT |
| 69 | // }; |
| 70 | // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", |
| 71 | // MyEnum::SOME_VALUE, MyEnum::COUNT); |
| 72 | // |
| 73 | // Note: If the enum is used in a switch, it is often desirable to avoid writing |
| 74 | // a case statement to handle an unused sentinel value (i.e. COUNT in the above |
| 75 | // example). For scoped enums, this is awkward since it requires casting the |
| 76 | // enum to an arithmetic type and adding one. Instead, prefer the two argument |
| 77 | // version of the macro which automatically deduces the boundary from kMaxValue. |
| 78 | #define UMA_HISTOGRAM_ENUMERATION(name, ...) \ |
| 79 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \ |
| 80 | __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \ |
| 81 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \ |
| 82 | (name, __VA_ARGS__, base::HistogramBase::kUmaTargetedHistogramFlag) |
| 83 |
| 84 | // As above but "scaled" count to avoid overflows caused by increments of |
| 85 | // large amounts. See UMA_HISTOGRAM_SCALED_EXACT_LINEAR for more information. |
| 86 | // Only the new format utilizing an internal kMaxValue is supported. |
| 87 | // It'll be necessary to #include "base/lazy_instance.h" to use this macro. |
| 88 | // name: Full constant name of the histogram (must not change between calls). |
| 89 | // sample: Bucket to be incremented. |
| 90 | // count: Amount by which to increment. |
| 91 | // scale: Amount by which |count| is divided. |
| 92 |
| 93 | // Sample usage: |
| 94 | // UMA_HISTOGRAM_SCALED_ENUMERATION("FooKiB", kEnumValue, byte_count, 1024) |
| 95 | #define UMA_HISTOGRAM_SCALED_ENUMERATION(name, sample, count, scale) \ |
| 96 | INTERNAL_HISTOGRAM_SCALED_ENUMERATION_WITH_FLAG( \ |
| 97 | name, sample, count, scale, \ |
| 98 | base::HistogramBase::kUmaTargetedHistogramFlag) |
| 99 |
| 100 | // Histogram for boolean values. |
| 101 |
| 102 | // Sample usage: |
| 103 | // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); |
| 104 | #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ |
| 105 | STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
| 106 | base::BooleanHistogram::FactoryGet(name, \ |
| 107 | base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 108 |
| 109 | //------------------------------------------------------------------------------ |
| 110 | // Linear histograms. |
| 111 |
| 112 | // All of these macros must be called with |name| as a runtime constant. |
| 113 |
| 114 | // Used for capturing integer data with a linear bucketing scheme. This can be |
| 115 | // used when you want the exact value of some small numeric count, with a max of |
| 116 | // 100 or less. If you need to capture a range of greater than 100, we recommend |
| 117 | // the use of the COUNT histograms below. |
| 118 |
| 119 | // Sample usage: |
| 120 | // UMA_HISTOGRAM_EXACT_LINEAR("Histogram.Linear", count, 10); |
| 121 | #define UMA_HISTOGRAM_EXACT_LINEAR(name, sample, value_max) \ |
| 122 | INTERNAL_HISTOGRAM_EXACT_LINEAR_WITH_FLAG( \ |
| 123 | name, sample, value_max, base::HistogramBase::kUmaTargetedHistogramFlag) |
| 124 |
| 125 | // Used for capturing basic percentages. This will be 100 buckets of size 1. |
| 126 |
| 127 | // Sample usage: |
| 128 | // UMA_HISTOGRAM_PERCENTAGE("Histogram.Percent", percent_as_int); |
| 129 | #define UMA_HISTOGRAM_PERCENTAGE(name, percent_as_int) \ |
| 130 | UMA_HISTOGRAM_EXACT_LINEAR(name, percent_as_int, 101) |
| 131 |
| 132 | //------------------------------------------------------------------------------ |
| 133 | // Scaled linear histograms. |
| 134 |
| 135 | // These take |count| and |scale| parameters to allow cumulative reporting of |
| 136 | // large numbers. For example, code might pass a count of 1825 bytes and a scale |
| 137 | // of 1024 bytes to report values in kilobytes. Only the scaled count is |
| 138 | // reported, but the remainder is tracked between calls, so that multiple calls |
| 139 | // will accumulate correctly. Only "exact linear" is supported. |
| 140 | // It'll be necessary to #include "base/lazy_instance.h" to use this macro. |
| 141 | // name: Full constant name of the histogram (must not change between calls). |
| 142 | // sample: Bucket to be incremented. |
| 143 | // count: Amount by which to increment. |
| 144 | // sample_max: Maximum (exclusive) allowed sample value. |
| 145 | // scale: Amount by which |count| is divided. |
| 146 |
| 147 | // Sample usage: |
| 148 | // UMA_HISTOGRAM_SCALED_EXACT_LINER("FooKiB", bucket_no, byte_count, |
| 149 | // kBucketsMax+1, 1024) |
| 150 | #define UMA_HISTOGRAM_SCALED_EXACT_LINEAR(name, sample, count, sample_max, \ |
| 151 | scale) \ |
| 152 | INTERNAL_HISTOGRAM_SCALED_EXACT_LINEAR_WITH_FLAG( \ |
| 153 | name, sample, count, sample_max, scale, \ |
| 154 | base::HistogramBase::kUmaTargetedHistogramFlag) |
| 155 |
| 156 | //------------------------------------------------------------------------------ |
| 157 | // Count histograms. These are used for collecting numeric data. Note that we |
| 158 | // have macros for more specialized use cases below (memory, time, percentages). |
| 159 |
| 160 | // The number suffixes here refer to the max size of the sample, i.e. COUNT_1000 |
| 161 | // will be able to collect samples of counts up to 1000. The default number of |
| 162 | // buckets in all default macros is 50. We recommend erring on the side of too |
| 163 | // large a range versus too short a range. |
| 164 | // These macros default to exponential histograms - i.e. the lengths of the |
| 165 | // bucket ranges exponentially increase as the sample range increases. |
| 166 | // These should *not* be used if you are interested in exact counts, i.e. a |
| 167 | // bucket range of 1. In these cases, you should use the ENUMERATION macros |
| 168 | // defined later. These should also not be used to capture the number of some |
| 169 | // event, i.e. "button X was clicked N times". In this cases, an enum should be |
| 170 | // used, ideally with an appropriate baseline enum entry included. |
| 171 | // All of these macros must be called with |name| as a runtime constant. |
| 172 |
| 173 | // Sample usage: |
| 174 | // UMA_HISTOGRAM_COUNTS_1M("My.Histogram", sample); |
| 175 |
| 176 | #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 177 | name, sample, 1, 100, 50) |
| 178 |
| 179 | #define UMA_HISTOGRAM_COUNTS_1000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 180 | name, sample, 1, 1000, 50) |
| 181 |
| 182 | #define UMA_HISTOGRAM_COUNTS_10000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 183 | name, sample, 1, 10000, 50) |
| 184 |
| 185 | #define UMA_HISTOGRAM_COUNTS_100000(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 186 | name, sample, 1, 100000, 50) |
| 187 |
| 188 | #define UMA_HISTOGRAM_COUNTS_1M(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 189 | name, sample, 1, 1000000, 50) |
| 190 |
| 191 | #define UMA_HISTOGRAM_COUNTS_10M(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 192 | name, sample, 1, 10000000, 50) |
| 193 |
| 194 | // This can be used when the default ranges are not sufficient. This macro lets |
| 195 | // the metric developer customize the min and max of the sampled range, as well |
| 196 | // as the number of buckets recorded. |
| 197 | // Any data outside the range here will be put in underflow and overflow |
| 198 | // buckets. Min values should be >=1 as emitted 0s will still go into the |
| 199 | // underflow bucket. |
| 200 |
| 201 | // Sample usage: |
| 202 | // UMA_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", sample, 1, 100000000, 50); |
| 203 | #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 204 | INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
| 205 | name, sample, min, max, bucket_count, \ |
| 206 | base::HistogramBase::kUmaTargetedHistogramFlag) |
| 207 |
| 208 | //------------------------------------------------------------------------------ |
| 209 | // Timing histograms. These are used for collecting timing data (generally |
| 210 | // latencies). |
| 211 |
| 212 | // These macros create exponentially sized histograms (lengths of the bucket |
| 213 | // ranges exponentially increase as the sample range increases). The input |
| 214 | // sample is a base::TimeDelta. The output data is measured in ms granularity. |
| 215 | // All of these macros must be called with |name| as a runtime constant. |
| 216 |
| 217 | // Sample usage: |
| 218 | // UMA_HISTOGRAM_TIMES("My.Timing.Histogram", time_delta); |
| 219 |
| 220 | // Short timings - up to 10 seconds. For high-resolution (microseconds) timings, |
| 221 | // see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES. |
| 222 | #define UMA_HISTOGRAM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 223 | name, sample, base::TimeDelta::FromMilliseconds(1), \ |
| 224 | base::TimeDelta::FromSeconds(10), 50) |
| 225 |
| 226 | // Medium timings - up to 3 minutes. Note this starts at 10ms (no good reason, |
| 227 | // but not worth changing). |
| 228 | #define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 229 | name, sample, base::TimeDelta::FromMilliseconds(10), \ |
| 230 | base::TimeDelta::FromMinutes(3), 50) |
| 231 |
| 232 | // Long timings - up to an hour. |
| 233 | #define UMA_HISTOGRAM_LONG_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 234 | name, sample, base::TimeDelta::FromMilliseconds(1), \ |
| 235 | base::TimeDelta::FromHours(1), 50) |
| 236 |
| 237 | // Long timings with higher granularity - up to an hour with 100 buckets. |
| 238 | #define UMA_HISTOGRAM_LONG_TIMES_100(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 239 | name, sample, base::TimeDelta::FromMilliseconds(1), \ |
| 240 | base::TimeDelta::FromHours(1), 100) |
| 241 |
| 242 | // This can be used when the default ranges are not sufficient. This macro lets |
| 243 | // the metric developer customize the min and max of the sampled range, as well |
| 244 | // as the number of buckets recorded. |
| 245 |
| 246 | // Sample usage: |
| 247 | // UMA_HISTOGRAM_CUSTOM_TIMES("Very.Long.Timing.Histogram", time_delta, |
| 248 | // base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(1), 100); |
| 249 | #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 250 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 251 | name, AddTimeMillisecondsGranularity(sample), \ |
| 252 | base::Histogram::FactoryTimeGet( \ |
| 253 | name, min, max, bucket_count, \ |
| 254 | base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 255 |
| 256 | // Same as UMA_HISTOGRAM_CUSTOM_TIMES but reports |sample| in microseconds, |
| 257 | // dropping the report if this client doesn't have a high-resolution clock. |
| 258 | // |
| 259 | // Note: dropping reports on clients with low-resolution clocks means these |
| 260 | // reports will be biased to a portion of the population on Windows. See |
| 261 | // Windows.HasHighResolutionTimeTicks for the affected sample. |
| 262 | // |
| 263 | // Sample usage: |
| 264 | // UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( |
| 265 | // "High.Resolution.TimingMicroseconds.Histogram", time_delta, |
| 266 | // base::TimeDelta::FromMicroseconds(1), |
| 267 | // base::TimeDelta::FromMilliseconds(10), 100); |
| 268 | #define UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sample, min, max, \ |
| 269 | bucket_count) \ |
| 270 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 271 | name, AddTimeMicrosecondsGranularity(sample), \ |
| 272 | base::Histogram::FactoryMicrosecondsTimeGet( \ |
| 273 | name, min, max, bucket_count, \ |
| 274 | base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 275 |
| 276 | // Scoped class which logs its time on this earth in milliseconds as a UMA |
| 277 | // statistic. This is recommended for when you want a histogram which measures |
| 278 | // the time it takes for a method to execute. This measures up to 10 seconds. It |
| 279 | // uses UMA_HISTOGRAM_TIMES under the hood. |
| 280 |
| 281 | // Sample usage: |
| 282 | // void Function() { |
| 283 | // SCOPED_UMA_HISTOGRAM_TIMER("Component.FunctionTime"); |
| 284 | // ... |
| 285 | // } |
| 286 | #define SCOPED_UMA_HISTOGRAM_TIMER(name) \ |
| 287 | INTERNAL_SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, false, __COUNTER__) |
| 288 |
| 289 | // Similar scoped histogram timer, but this uses UMA_HISTOGRAM_LONG_TIMES_100, |
| 290 | // which measures up to an hour, and uses 100 buckets. This is more expensive |
| 291 | // to store, so only use if this often takes >10 seconds. |
| 292 | #define SCOPED_UMA_HISTOGRAM_LONG_TIMER(name) \ |
| 293 | INTERNAL_SCOPED_UMA_HISTOGRAM_TIMER_EXPANDER(name, true, __COUNTER__) |
| 294 |
| 295 |
| 296 | //------------------------------------------------------------------------------ |
| 297 | // Memory histograms. |
| 298 |
| 299 | // These macros create exponentially sized histograms (lengths of the bucket |
| 300 | // ranges exponentially increase as the sample range increases). The input |
| 301 | // sample must be a number measured in kilobytes. |
| 302 | // All of these macros must be called with |name| as a runtime constant. |
| 303 |
| 304 | // Sample usage: |
| 305 | // UMA_HISTOGRAM_MEMORY_KB("My.Memory.Histogram", memory_in_kb); |
| 306 |
| 307 | // Used to measure common KB-granularity memory stats. Range is up to 500000KB - |
| 308 | // approximately 500M. |
| 309 | #define UMA_HISTOGRAM_MEMORY_KB(name, sample) \ |
| 310 | UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1000, 500000, 50) |
| 311 |
| 312 | // Used to measure common MB-granularity memory stats. Range is up to ~64G. |
| 313 | #define UMA_HISTOGRAM_MEMORY_LARGE_MB(name, sample) \ |
| 314 | UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 64000, 100) |
| 315 |
| 316 |
| 317 | //------------------------------------------------------------------------------ |
| 318 | // Stability-specific histograms. |
| 319 |
| 320 | // Histograms logged in as stability histograms will be included in the initial |
| 321 | // stability log. See comments by declaration of |
| 322 | // MetricsService::PrepareInitialStabilityLog(). |
| 323 | // All of these macros must be called with |name| as a runtime constant. |
| 324 |
| 325 | // For details on usage, see the documentation on the non-stability equivalents. |
| 326 |
| 327 | #define UMA_STABILITY_HISTOGRAM_BOOLEAN(name, sample) \ |
| 328 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 329 | name, AddBoolean(sample), \ |
| 330 | base::BooleanHistogram::FactoryGet( \ |
| 331 | name, base::HistogramBase::kUmaStabilityHistogramFlag)) |
| 332 |
| 333 | #define UMA_STABILITY_HISTOGRAM_COUNTS_100(name, sample) \ |
| 334 | UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) |
| 335 |
| 336 | #define UMA_STABILITY_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, \ |
| 337 | bucket_count) \ |
| 338 | INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
| 339 | name, sample, min, max, bucket_count, \ |
| 340 | base::HistogramBase::kUmaStabilityHistogramFlag) |
| 341 |
| 342 | #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, ...) \ |
| 343 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \ |
| 344 | __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \ |
| 345 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \ |
| 346 | (name, __VA_ARGS__, base::HistogramBase::kUmaStabilityHistogramFlag) |
| 347 |
| 348 | #define UMA_STABILITY_HISTOGRAM_LONG_TIMES(name, sample) \ |
| 349 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 350 | name, AddTimeMillisecondsGranularity(sample), \ |
| 351 | base::Histogram::FactoryTimeGet( \ |
| 352 | name, base::TimeDelta::FromMilliseconds(1), \ |
| 353 | base::TimeDelta::FromHours(1), 50, \ |
| 354 | base::HistogramBase::kUmaStabilityHistogramFlag)) |
| 355 |
| 356 | #define UMA_STABILITY_HISTOGRAM_PERCENTAGE(name, percent_as_int) \ |
| 357 | INTERNAL_HISTOGRAM_EXACT_LINEAR_WITH_FLAG( \ |
| 358 | name, percent_as_int, 101, \ |
| 359 | base::HistogramBase::kUmaStabilityHistogramFlag) |
| 360 |
| 361 | //------------------------------------------------------------------------------ |
| 362 | // Histogram instantiation helpers. |
| 363 |
| 364 | // Support a collection of histograms, perhaps one for each entry in an |
| 365 | // enumeration. This macro manages a block of pointers, adding to a specific |
| 366 | // one by its index. |
| 367 | // |
| 368 | // A typical instantiation looks something like this: |
| 369 | // STATIC_HISTOGRAM_POINTER_GROUP( |
| 370 | // GetHistogramNameForIndex(histogram_index), |
| 371 | // histogram_index, MAXIMUM_HISTOGRAM_INDEX, Add(some_delta), |
| 372 | // base::Histogram::FactoryGet( |
| 373 | // GetHistogramNameForIndex(histogram_index), |
| 374 | // MINIMUM_SAMPLE, MAXIMUM_SAMPLE, BUCKET_COUNT, |
| 375 | // base::HistogramBase::kUmaTargetedHistogramFlag)); |
| 376 | // |
| 377 | // Though it seems inefficient to generate the name twice, the first |
| 378 | // instance will be used only for DCHECK builds and the second will |
| 379 | // execute only during the first access to the given index, after which |
| 380 | // the pointer is cached and the name never needed again. |
| 381 | #define STATIC_HISTOGRAM_POINTER_GROUP( \ |
| 382 | constant_histogram_name, index, constant_maximum, \ |
| 383 | histogram_add_method_invocation, histogram_factory_get_invocation) \ |
| 384 | do { \ |
| 385 | static std::atomic_uintptr_t atomic_histograms[constant_maximum]; \ |
| 386 | DCHECK_LE(0, index); \ |
| 387 | DCHECK_LT(index, constant_maximum); \ |
| 388 | HISTOGRAM_POINTER_USE( \ |
| 389 | std::addressof(atomic_histograms[index]), constant_histogram_name, \ |
| 390 | histogram_add_method_invocation, histogram_factory_get_invocation); \ |
| 391 | } while (0) |
| 392 |
| 393 | //------------------------------------------------------------------------------ |
| 394 | // Deprecated histogram macros. Not recommended for current use. |
| 395 |
| 396 | // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming |
| 397 | // and not using this macro going forward. |
| 398 | #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 399 | name, sample, 1, 1000000, 50) |
| 400 |
| 401 | // MB-granularity memory metric. This has a short max (1G). |
| 402 | #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \ |
| 403 | UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50) |
| 404 |
| 405 | // For an enum with customized range. In general, sparse histograms should be |
| 406 | // used instead. |
| 407 | // Samples should be one of the std::vector<int> list provided via |
| 408 | // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
| 409 | // requirement of |custom_ranges|. You can use the helper function |
| 410 | // CustomHistogram::ArrayToCustomEnumRanges to transform a C-style array of |
| 411 | // valid sample values to a std::vector<int>. |
| 412 | #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
| 413 | STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 414 | base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
| 415 | base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 416 |
| 417 | #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
| 418 |