| OLD | NEW |
| 1 // | 1 // |
| 2 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 // | 3 // |
| 4 // Use of this source code is governed by a BSD-style license | 4 // Use of this source code is governed by a BSD-style license |
| 5 // that can be found in the LICENSE file in the root of the source | 5 // that can be found in the LICENSE file in the root of the source |
| 6 // tree. An additional intellectual property rights grant can be found | 6 // tree. An additional intellectual property rights grant can be found |
| 7 // in the file PATENTS. All contributing project authors may | 7 // in the file PATENTS. All contributing project authors may |
| 8 // be found in the AUTHORS file in the root of the source tree. | 8 // be found in the AUTHORS file in the root of the source tree. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 #define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \ | 86 #define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \ |
| 87 RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ | 87 RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ |
| 88 webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) | 88 webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) |
| 89 | 89 |
| 90 #define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \ | 90 #define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \ |
| 91 RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ | 91 RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ |
| 92 webrtc::metrics::HistogramFactoryGetCountsLinear( \ | 92 webrtc::metrics::HistogramFactoryGetCountsLinear( \ |
| 93 name, min, max, bucket_count)) | 93 name, min, max, bucket_count)) |
| 94 | 94 |
| 95 // Deprecated. | 95 // Slow metrics: pointer to metric is acquired at each call and is not cached. |
| 96 // TODO(asapersson): Remove. | 96 // |
| 97 #define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \ | 97 #define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \ |
| 98 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100, 50) | 98 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100, 50) |
| 99 | 99 |
| 100 #define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) \ |
| 101 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 200, 50) |
| 102 |
| 103 #define RTC_HISTOGRAM_COUNTS_SPARSE_500(name, sample) \ |
| 104 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 500, 50) |
| 105 |
| 106 #define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) \ |
| 107 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 1000, 50) |
| 108 |
| 109 #define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) \ |
| 110 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 10000, 50) |
| 111 |
| 112 #define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) \ |
| 113 RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100000, 50) |
| 114 |
| 100 #define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \ | 115 #define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \ |
| 101 RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \ | 116 RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \ |
| 102 webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) | 117 webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) |
| 103 | 118 |
| 104 // Histogram for percentage (evenly spaced buckets). | 119 // Histogram for percentage (evenly spaced buckets). |
| 120 #define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) \ |
| 121 RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 101) |
| 122 |
| 123 // Histogram for booleans. |
| 124 #define RTC_HISTOGRAM_BOOLEAN_SPARSE(name, sample) \ |
| 125 RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 2) |
| 126 |
| 127 // Histogram for enumerators (evenly spaced buckets). |
| 128 // |boundary| should be above the max enumerator sample. |
| 129 #define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \ |
| 130 RTC_HISTOGRAM_COMMON_BLOCK_SLOW( \ |
| 131 name, sample, \ |
| 132 webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary)) |
| 133 |
| 134 // Histogram for percentage (evenly spaced buckets). |
| 105 #define RTC_HISTOGRAM_PERCENTAGE(name, sample) \ | 135 #define RTC_HISTOGRAM_PERCENTAGE(name, sample) \ |
| 106 RTC_HISTOGRAM_ENUMERATION(name, sample, 101) | 136 RTC_HISTOGRAM_ENUMERATION(name, sample, 101) |
| 107 | 137 |
| 108 // Histogram for booleans. | 138 // Histogram for booleans. |
| 109 #define RTC_HISTOGRAM_BOOLEAN(name, sample) \ | 139 #define RTC_HISTOGRAM_BOOLEAN(name, sample) \ |
| 110 RTC_HISTOGRAM_ENUMERATION(name, sample, 2) | 140 RTC_HISTOGRAM_ENUMERATION(name, sample, 2) |
| 111 | 141 |
| 112 // Histogram for enumerators (evenly spaced buckets). | 142 // Histogram for enumerators (evenly spaced buckets). |
| 113 // |boundary| should be above the max enumerator sample. | 143 // |boundary| should be above the max enumerator sample. |
| 114 #define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \ | 144 #define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 #define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \ | 177 #define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \ |
| 148 do { \ | 178 do { \ |
| 149 webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \ | 179 webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \ |
| 150 if (histogram_pointer) { \ | 180 if (histogram_pointer) { \ |
| 151 webrtc::metrics::HistogramAdd(histogram_pointer, sample); \ | 181 webrtc::metrics::HistogramAdd(histogram_pointer, sample); \ |
| 152 } \ | 182 } \ |
| 153 } while (0) | 183 } while (0) |
| 154 | 184 |
| 155 // Helper macros. | 185 // Helper macros. |
| 156 // Macros for calling a histogram with varying name (e.g. when using a metric | 186 // Macros for calling a histogram with varying name (e.g. when using a metric |
| 157 // in different modes such as real-time vs screenshare). | 187 // in different modes such as real-time vs screenshare). Fast, because pointer |
| 188 // is cached. |index| should be different for different names. Allowed |index| |
| 189 // values are 0, 1, and 2. |
| 158 #define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \ | 190 #define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \ |
| 159 RTC_HISTOGRAMS_COMMON(index, name, sample, \ | 191 RTC_HISTOGRAMS_COMMON(index, name, sample, \ |
| 160 RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50)) | 192 RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50)) |
| 161 | 193 |
| 162 #define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \ | 194 #define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \ |
| 163 RTC_HISTOGRAMS_COMMON(index, name, sample, \ | 195 RTC_HISTOGRAMS_COMMON(index, name, sample, \ |
| 164 RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50)) | 196 RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50)) |
| 165 | 197 |
| 166 #define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) \ | 198 #define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) \ |
| 167 RTC_HISTOGRAMS_COMMON(index, name, sample, \ | 199 RTC_HISTOGRAMS_COMMON(index, name, sample, \ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 181 | 213 |
| 182 #define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \ | 214 #define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \ |
| 183 RTC_HISTOGRAMS_COMMON(index, name, sample, \ | 215 RTC_HISTOGRAMS_COMMON(index, name, sample, \ |
| 184 RTC_HISTOGRAM_ENUMERATION(name, sample, boundary)) | 216 RTC_HISTOGRAM_ENUMERATION(name, sample, boundary)) |
| 185 | 217 |
| 186 #define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \ | 218 #define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \ |
| 187 RTC_HISTOGRAMS_COMMON(index, name, sample, \ | 219 RTC_HISTOGRAMS_COMMON(index, name, sample, \ |
| 188 RTC_HISTOGRAM_PERCENTAGE(name, sample)) | 220 RTC_HISTOGRAM_PERCENTAGE(name, sample)) |
| 189 | 221 |
| 190 #define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \ | 222 #define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \ |
| 191 do { \ | 223 do { \ |
| 192 switch (index) { \ | 224 switch (index) { \ |
| 193 case 0: \ | 225 case 0: \ |
| 194 macro_invocation; \ | 226 macro_invocation; \ |
| 195 break; \ | 227 break; \ |
| 196 case 1: \ | 228 case 1: \ |
| 197 macro_invocation; \ | 229 macro_invocation; \ |
| 198 break; \ | 230 break; \ |
| 199 case 2: \ | 231 case 2: \ |
| 200 macro_invocation; \ | 232 macro_invocation; \ |
| 201 break; \ | 233 break; \ |
| 202 default: \ | 234 default: \ |
| 203 RTC_NOTREACHED(); \ | 235 RTC_NOTREACHED(); \ |
| 204 } \ | 236 } \ |
| 205 } while (0) | 237 } while (0) |
| 206 | 238 |
| 207 | |
| 208 namespace webrtc { | 239 namespace webrtc { |
| 209 namespace metrics { | 240 namespace metrics { |
| 210 | 241 |
| 211 // Time that should have elapsed for stats that are gathered once per call. | 242 // Time that should have elapsed for stats that are gathered once per call. |
| 212 enum { kMinRunTimeInSeconds = 10 }; | 243 enum { kMinRunTimeInSeconds = 10 }; |
| 213 | 244 |
| 214 class Histogram; | 245 class Histogram; |
| 215 | 246 |
| 216 // Functions for getting pointer to histogram (constructs or finds the named | 247 // Functions for getting pointer to histogram (constructs or finds the named |
| 217 // histogram). | 248 // histogram). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 234 // Returns name of the histogram. | 265 // Returns name of the histogram. |
| 235 const std::string& GetHistogramName(Histogram* histogram_pointer); | 266 const std::string& GetHistogramName(Histogram* histogram_pointer); |
| 236 | 267 |
| 237 // Function for adding a |sample| to a histogram. | 268 // Function for adding a |sample| to a histogram. |
| 238 void HistogramAdd(Histogram* histogram_pointer, int sample); | 269 void HistogramAdd(Histogram* histogram_pointer, int sample); |
| 239 | 270 |
| 240 } // namespace metrics | 271 } // namespace metrics |
| 241 } // namespace webrtc | 272 } // namespace webrtc |
| 242 | 273 |
| 243 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ | 274 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ |
| OLD | NEW |