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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // Histogram for boolean values. | 46 // Histogram for boolean values. |
47 | 47 |
48 // Sample usage: | 48 // Sample usage: |
49 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); | 49 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); |
50 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ | 50 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ |
51 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ | 51 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ |
52 base::BooleanHistogram::FactoryGet(name, \ | 52 base::BooleanHistogram::FactoryGet(name, \ |
53 base::HistogramBase::kUmaTargetedHistogramFlag)) | 53 base::HistogramBase::kUmaTargetedHistogramFlag)) |
54 | 54 |
55 //------------------------------------------------------------------------------ | 55 //------------------------------------------------------------------------------ |
56 // Percentage histograms. | 56 // Linear histograms. |
57 | 57 |
58 // All of these macros must be called with |name| as a runtime constant. | 58 // All of these macros must be called with |name| as a runtime constant. |
59 | 59 |
60 // Used for capturing integer data with a linear bucketing scheme. This can be | |
61 // used when you want the exact value of some small numeric count, with a max of | |
62 // 100 or less. If you need to capture a range of greater than 100, we recommend | |
63 // the use of the COUNT histograms below. | |
64 | |
65 // Sample usage: | |
66 // UMA_HISTOGRAM_EXACT_LINEAR("Histogram.Linear", count, 10); | |
67 #define UMA_HISTOGRAM_EXACT_LINEAR(name, sample, value_max) \ | |
68 UMA_HISTOGRAM_ENUMERATION(name, sample, value_max) | |
Mark P
2016/10/03 17:42:29
Should we make this value_max+1 to better detect c
rkaplow
2016/10/03 19:19:44
sure, that sounds good, although we do want to do
| |
69 | |
70 | |
Mark P
2016/10/03 17:42:29
optional nit: remove one black line
| |
60 // Used for capturing basic percentages. This will be 100 buckets of size 1. | 71 // Used for capturing basic percentages. This will be 100 buckets of size 1. |
61 | 72 |
62 // Sample usage: | 73 // Sample usage: |
63 // UMA_HISTOGRAM_PERCENTAGE("Histogram.Percent", percent_as_int); | 74 // UMA_HISTOGRAM_PERCENTAGE("Histogram.Percent", percent_as_int); |
64 #define UMA_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 75 #define UMA_HISTOGRAM_PERCENTAGE(name, percent_as_int) \ |
65 UMA_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 76 UMA_HISTOGRAM_ENUMERATION(name, percent_as_int, 101) |
66 | |
67 | 77 |
68 //------------------------------------------------------------------------------ | 78 //------------------------------------------------------------------------------ |
69 // Count histograms. These are used for collecting numeric data. Note that we | 79 // Count histograms. These are used for collecting numeric data. Note that we |
70 // have macros for more specialized use cases below (memory, time, percentages). | 80 // have macros for more specialized use cases below (memory, time, percentages). |
71 | 81 |
72 // The number suffixes here refer to the max size of the sample, i.e. COUNT_1000 | 82 // The number suffixes here refer to the max size of the sample, i.e. COUNT_1000 |
73 // will be able to collect samples of counts up to 1000. The default number of | 83 // will be able to collect samples of counts up to 1000. The default number of |
74 // buckets in all default macros is 50. We recommend erring on the side of too | 84 // buckets in all default macros is 50. We recommend erring on the side of too |
75 // large a range versus too short a range. | 85 // large a range versus too short a range. |
76 // These macros default to exponential histograms - i.e. the lengths of the | 86 // These macros default to exponential histograms - i.e. the lengths of the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // buckets. Min values should be >=1 as emitted 0s will still go into the | 120 // buckets. Min values should be >=1 as emitted 0s will still go into the |
111 // underflow bucket. | 121 // underflow bucket. |
112 | 122 |
113 // Sample usage: | 123 // Sample usage: |
114 // UMA_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000, 100); | 124 // UMA_HISTOGRAM_CUSTOM_COUNTS("My.Histogram", 1, 100000000, 100); |
115 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ | 125 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
116 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ | 126 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ |
117 name, sample, min, max, bucket_count, \ | 127 name, sample, min, max, bucket_count, \ |
118 base::HistogramBase::kUmaTargetedHistogramFlag) | 128 base::HistogramBase::kUmaTargetedHistogramFlag) |
119 | 129 |
120 | |
121 //------------------------------------------------------------------------------ | 130 //------------------------------------------------------------------------------ |
122 // Timing histograms. These are used for collecting timing data (generally | 131 // Timing histograms. These are used for collecting timing data (generally |
123 // latencies). | 132 // latencies). |
124 | 133 |
125 // These macros create exponentially sized histograms (lengths of the bucket | 134 // These macros create exponentially sized histograms (lengths of the bucket |
126 // ranges exponentially increase as the sample range increases). The input | 135 // ranges exponentially increase as the sample range increases). The input |
127 // sample is a base::TimeDelta. The output data is measured in ms granularity. | 136 // sample is a base::TimeDelta. The output data is measured in ms granularity. |
128 // All of these macros must be called with |name| as a runtime constant. | 137 // All of these macros must be called with |name| as a runtime constant. |
129 | 138 |
130 // Sample usage: | 139 // Sample usage: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the | 256 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
248 // requirement of |custom_ranges|. You can use the helper function | 257 // requirement of |custom_ranges|. You can use the helper function |
249 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid | 258 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid |
250 // sample values to a std::vector<int>. | 259 // sample values to a std::vector<int>. |
251 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 260 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
252 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 261 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
253 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 262 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
254 base::HistogramBase::kUmaTargetedHistogramFlag)) | 263 base::HistogramBase::kUmaTargetedHistogramFlag)) |
255 | 264 |
256 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 265 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |