Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_ |
| 6 | #define BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_ |
| 7 | |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 8 | #include "base/metrics/histogram.h" |
| 9 | #include "base/metrics/histogram_macros_internal.h" |
| 10 | #include "base/time/time.h" |
| 11 | |
| 12 | // TODO(rkaplow): Migrate all LOCAL_* usage within Chromium to include this |
| 13 | // file instead of the histogram_macros.h file. |
| 14 | |
| 15 | //------------------------------------------------------------------------------ |
| 16 | // Enumeration histograms. |
| 17 | // |
| 18 | // For usage details, see the equivalents in histogram_macros.h. |
| 19 | |
Daniel Cheng | a67dd55 | 2018-03-31 02:30:46 | [diff] [blame] | 20 | #define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \ |
Avi Drissman | b00a9e7e | 2018-10-12 01:01:56 | [diff] [blame] | 21 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \ |
Daniel Cheng | a67dd55 | 2018-03-31 02:30:46 | [diff] [blame] | 22 | __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \ |
Avi Drissman | b00a9e7e | 2018-10-12 01:01:56 | [diff] [blame] | 23 | INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \ |
| 24 | (name, __VA_ARGS__, base::HistogramBase::kNoFlags) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 25 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 26 | #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \ |
| 27 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 28 | name, AddBoolean(sample), \ |
| 29 | base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags)) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 30 | |
| 31 | //------------------------------------------------------------------------------ |
| 32 | // Percentage histograms. |
| 33 | // |
| 34 | // For usage details, see the equivalents in histogram_macros.h |
| 35 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 36 | #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 37 | LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 38 | |
| 39 | //------------------------------------------------------------------------------ |
| 40 | // Count histograms. These are used for collecting numeric data. Note that we |
| 41 | // have macros for more specialized use cases below (memory, time, percentages). |
| 42 | // For usage details, see the equivalents in histogram_macros.h. |
| 43 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 44 | #define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \ |
| 45 | LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 46 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 47 | #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \ |
| 48 | LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 49 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 50 | #define LOCAL_HISTOGRAM_COUNTS_1000000(name, sample) \ |
| 51 | LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 52 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 53 | #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 54 | INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
| 55 | name, sample, min, max, bucket_count, base::HistogramBase::kNoFlags) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 56 | |
| 57 | //------------------------------------------------------------------------------ |
| 58 | // Timing histograms. These are used for collecting timing data (generally |
| 59 | // latencies). |
| 60 | // |
| 61 | // For usage details, see the equivalents in histogram_macros.h. |
| 62 | |
Peter Kasting | e5a38ed | 2021-10-02 03:06:35 | [diff] [blame] | 63 | #define LOCAL_HISTOGRAM_TIMES(name, sample) \ |
| 64 | LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \ |
| 65 | base::Seconds(10), 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 66 | |
Gabriel Charette | 5ec20588 | 2018-05-22 18:07:31 | [diff] [blame] | 67 | #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 68 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 69 | name, AddTimeMillisecondsGranularity(sample), \ |
| 70 | base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ |
| 71 | base::HistogramBase::kNoFlags)) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 72 | |
Vasiliy Telezhnikov | e7b3c7e | 2020-11-19 14:33:55 | [diff] [blame] | 73 | #define LOCAL_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sample, min, max, \ |
| 74 | bucket_count) \ |
| 75 | STATIC_HISTOGRAM_POINTER_BLOCK( \ |
| 76 | name, AddTimeMicrosecondsGranularity(sample), \ |
| 77 | base::Histogram::FactoryMicrosecondsTimeGet( \ |
| 78 | name, min, max, bucket_count, base::HistogramBase::kNoFlags)) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 79 | //------------------------------------------------------------------------------ |
| 80 | // Memory histograms. |
| 81 | // |
| 82 | // For usage details, see the equivalents in histogram_macros.h. |
| 83 | |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 84 | #define LOCAL_HISTOGRAM_MEMORY_KB(name, sample) \ |
| 85 | LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1000, 500000, 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 86 | |
| 87 | //------------------------------------------------------------------------------ |
| 88 | // Deprecated histograms. Not recommended for current use. |
| 89 | |
| 90 | // TODO(rkaplow): See if we can clean up this macro and usage. |
| 91 | // Legacy non-explicit version. We suggest using LOCAL_HISTOGRAM_COUNTS_1000000 |
| 92 | // instead. |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 93 | #define LOCAL_HISTOGRAM_COUNTS(name, sample) \ |
| 94 | LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50) |
rkaplow | a1ee205 | 2016-09-27 17:12:08 | [diff] [blame] | 95 | |
| 96 | #endif // BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_ |