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

Unified 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: address comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/system_wrappers/source/metrics_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/system_wrappers/include/metrics.h
diff --git a/webrtc/system_wrappers/include/metrics.h b/webrtc/system_wrappers/include/metrics.h
index 4cd74c5e845f8f43ef14433470902f4016b89e2d..ce193bdc39bc897bc10431ffff2ba27075267718 100644
--- a/webrtc/system_wrappers/include/metrics.h
+++ b/webrtc/system_wrappers/include/metrics.h
@@ -153,6 +153,58 @@
webrtc::metrics::HistogramAdd(histogram_pointer, name, sample); \
} while (0)
+
+// Helper macros.
+// Macros for calling a histogram with varying name (e.g. when using a metric
+// in different modes such as real-time vs screenshare).
+#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50))
+
+#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50))
+
+#define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50))
+
+#define RTC_HISTOGRAMS_COUNTS_10000(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50))
+
+#define RTC_HISTOGRAMS_COUNTS_100000(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50))
+
+#define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_ENUMERATION(name, sample, boundary))
+
+#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \
+ RTC_HISTOGRAMS_COMMON(index, name, sample, \
+ RTC_HISTOGRAM_PERCENTAGE(name, sample))
+
+#define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
+ do { \
+ RTC_DCHECK(index >= 0); \
+ RTC_DCHECK(index <= 2); \
+ switch (index) { \
+ case 0: \
+ macro_invocation; \
+ break; \
+ case 1: \
+ macro_invocation; \
+ break; \
+ case 2: \
+ macro_invocation; \
+ break; \
+ default: \
+ RTC_NOTREACHED(); \
+ } \
+ } while (0)
+
+
namespace webrtc {
namespace metrics {
« 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