Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: webrtc/system_wrappers/include/metrics.h

Issue 1567013004: Add helper macros for calling a histogram with different names. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/system_wrappers/source/metrics_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Deprecated. 147 // Deprecated.
148 // The histogram is constructed/found for each call. 148 // The histogram is constructed/found for each call.
149 // May be used for histograms with infrequent updates. 149 // May be used for histograms with infrequent updates.
150 #define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \ 150 #define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \
151 do { \ 151 do { \
152 webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \ 152 webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \
153 webrtc::metrics::HistogramAdd(histogram_pointer, name, sample); \ 153 webrtc::metrics::HistogramAdd(histogram_pointer, name, sample); \
154 } while (0) 154 } while (0)
155 155
156
157 // Helper macros.
158 // Macros for calling a histogram with varying name (e.g. when using a metric
159 // in different modes such as real-time vs screenshare).
160 #define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
161 RTC_HISTOGRAMS_COMMON(index, name, sample, \
162 RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50))
163
164 #define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \
165 RTC_HISTOGRAMS_COMMON(index, name, sample, \
166 RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50))
167
168 #define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
169 RTC_HISTOGRAMS_COMMON(index, name, sample, \
170 RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50))
171
172 #define RTC_HISTOGRAMS_COUNTS_10000(index, name, sample) \
173 RTC_HISTOGRAMS_COMMON(index, name, sample, \
174 RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50))
175
176 #define RTC_HISTOGRAMS_COUNTS_100000(index, name, sample) \
177 RTC_HISTOGRAMS_COMMON(index, name, sample, \
178 RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50))
179
180 #define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
181 RTC_HISTOGRAMS_COMMON(index, name, sample, \
182 RTC_HISTOGRAM_ENUMERATION(name, sample, boundary))
183
184 #define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \
185 RTC_HISTOGRAMS_COMMON(index, name, sample, \
186 RTC_HISTOGRAM_PERCENTAGE(name, sample))
187
188 #define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
189 do { \
190 RTC_DCHECK_GE(index, 0); \
pbos-webrtc 2016/01/19 14:13:35 RTC_DCHECK(index >= 0) so you can use both size_t
åsapersson 2016/01/20 10:50:52 Done.
191 RTC_DCHECK_LE(index, 2); \
192 switch (index) { \
193 case 0: \
194 macro_invocation; \
195 break; \
196 case 1: \
197 macro_invocation; \
198 break; \
199 case 2: \
200 macro_invocation; \
201 break; \
202 default: \
203 RTC_NOTREACHED(); \
204 } \
205 } while (0)
206
207
156 namespace webrtc { 208 namespace webrtc {
157 namespace metrics { 209 namespace metrics {
158 210
159 // Time that should have elapsed for stats that are gathered once per call. 211 // Time that should have elapsed for stats that are gathered once per call.
160 enum { kMinRunTimeInSeconds = 10 }; 212 enum { kMinRunTimeInSeconds = 10 };
161 213
162 class Histogram; 214 class Histogram;
163 215
164 // Functions for getting pointer to histogram (constructs or finds the named 216 // Functions for getting pointer to histogram (constructs or finds the named
165 // histogram). 217 // histogram).
(...skipping 10 matching lines...) Expand all
176 // Function for adding a |sample| to a histogram. 228 // Function for adding a |sample| to a histogram.
177 // |name| can be used to verify that it matches the histogram name. 229 // |name| can be used to verify that it matches the histogram name.
178 void HistogramAdd( 230 void HistogramAdd(
179 Histogram* histogram_pointer, const std::string& name, int sample); 231 Histogram* histogram_pointer, const std::string& name, int sample);
180 232
181 } // namespace metrics 233 } // namespace metrics
182 } // namespace webrtc 234 } // namespace webrtc
183 235
184 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_ 236 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_H_
185 237
OLDNEW
« no previous file with comments | « no previous file | webrtc/system_wrappers/source/metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698