| 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/metrics/histogram_macros_internal.h" | 9 #include "base/metrics/histogram_macros_internal.h" |
| 10 #include "base/metrics/histogram_macros_local.h" | 10 #include "base/metrics/histogram_macros_local.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // infrequently recorded values since the implementation is slower | 249 // infrequently recorded values since the implementation is slower |
| 250 // and takes more memory. | 250 // and takes more memory. |
| 251 // | 251 // |
| 252 // For instance, Sqlite.Version.* are sparse because for any given database, | 252 // For instance, Sqlite.Version.* are sparse because for any given database, |
| 253 // there's going to be exactly one version logged. | 253 // there's going to be exactly one version logged. |
| 254 // The |sample| can be a negative or non-negative number. | 254 // The |sample| can be a negative or non-negative number. |
| 255 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 255 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
| 256 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) | 256 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) |
| 257 | 257 |
| 258 //------------------------------------------------------------------------------ | 258 //------------------------------------------------------------------------------ |
| 259 // Histogram instantiation helpers. |
| 260 |
| 261 // Support a collection of histograms, perhaps one for each entry in an |
| 262 // enumeration. This macro manages a block of pointers, adding to a specific |
| 263 // one by its index. |
| 264 // |
| 265 // A typical instantiation looks something like this: |
| 266 // STATIC_HISTOGRAM_POINTER_GROUP( |
| 267 // GetHistogramNameForIndex(histogram_index), |
| 268 // histogram_index, MAXIMUM_HISTOGRAM_INDEX, Add(some_delta), |
| 269 // base::Histogram::FactoryGet( |
| 270 // GetHistogramNameForIndex(histogram_index), |
| 271 // MINIMUM_SAMPLE, MAXIMUM_SAMPLE, BUCKET_COUNT, |
| 272 // base::HistogramBase::kUmaTargetedHistogramFlag)); |
| 273 // |
| 274 // Though it seems inefficient to generate the name twice, the first |
| 275 // instance will be used only for DCHECK builds and the second will |
| 276 // execute only during the first access to the given index, after which |
| 277 // the pointer is cached and the name never needed again. |
| 278 #define STATIC_HISTOGRAM_POINTER_GROUP(constant_histogram_name, index, \ |
| 279 constant_maximum, \ |
| 280 histogram_add_method_invocation, \ |
| 281 histogram_factory_get_invocation) \ |
| 282 do { \ |
| 283 static base::subtle::AtomicWord atomic_histograms[constant_maximum]; \ |
| 284 DCHECK_LE(0, index); \ |
| 285 DCHECK_LT(index, constant_maximum); \ |
| 286 HISTOGRAM_POINTER_USE(&atomic_histograms[index], constant_histogram_name, \ |
| 287 histogram_add_method_invocation, \ |
| 288 histogram_factory_get_invocation); \ |
| 289 } while (0) |
| 290 |
| 291 //------------------------------------------------------------------------------ |
| 259 // Deprecated histogram macros. Not recommended for current use. | 292 // Deprecated histogram macros. Not recommended for current use. |
| 260 | 293 |
| 261 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming | 294 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming |
| 262 // and not using this macro going forward. | 295 // and not using this macro going forward. |
| 263 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 296 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 264 name, sample, 1, 1000000, 50) | 297 name, sample, 1, 1000000, 50) |
| 265 | 298 |
| 266 // MB-granularity memory metric. This has a short max (1G). | 299 // MB-granularity memory metric. This has a short max (1G). |
| 267 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \ | 300 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \ |
| 268 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50) | 301 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50) |
| 269 | 302 |
| 270 // For an enum with customized range. In general, sparse histograms should be | 303 // For an enum with customized range. In general, sparse histograms should be |
| 271 // used instead. | 304 // used instead. |
| 272 // Samples should be one of the std::vector<int> list provided via | 305 // Samples should be one of the std::vector<int> list provided via |
| 273 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the | 306 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
| 274 // requirement of |custom_ranges|. You can use the helper function | 307 // requirement of |custom_ranges|. You can use the helper function |
| 275 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid | 308 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid |
| 276 // sample values to a std::vector<int>. | 309 // sample values to a std::vector<int>. |
| 277 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 310 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
| 278 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 311 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
| 279 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 312 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
| 280 base::HistogramBase::kUmaTargetedHistogramFlag)) | 313 base::HistogramBase::kUmaTargetedHistogramFlag)) |
| 281 | 314 |
| 282 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 315 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
| OLD | NEW |