Use the sparse histogram in RTC_HISTOGRAM_ENUMERATION_SPARSE.
A stub of sparse histogram factory getter is added so that Chromium can
provide an implementation using base::SparseHistogram for the metrics
macro RTC_HISTOGRAM_ENUMERATION_SPARSE. The default implementation in
WebRTC reuses the non-sparse version.
Bug: None
Change-Id: Ia091ca7aaacb6baa92027cd99d821bbc8da8d780
Reviewed-on: https://webrtc-review.googlesource.com/85740
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@google.com>
Cr-Commit-Position: refs/heads/master@{#23750}
diff --git a/system_wrappers/include/metrics.h b/system_wrappers/include/metrics.h
index 13f2483..13ed2c9 100644
--- a/system_wrappers/include/metrics.h
+++ b/system_wrappers/include/metrics.h
@@ -128,9 +128,9 @@
// Histogram for enumerators (evenly spaced buckets).
// |boundary| should be above the max enumerator sample.
#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \
- RTC_HISTOGRAM_COMMON_BLOCK_SLOW( \
+ RTC_HISTOGRAM_COMMON_BLOCK( \
name, sample, \
- webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary))
+ webrtc::metrics::SparseHistogramFactoryGetEnumeration(name, boundary))
// Histogram for percentage (evenly spaced buckets).
#define RTC_HISTOGRAM_PERCENTAGE(name, sample) \
@@ -263,6 +263,11 @@
Histogram* HistogramFactoryGetEnumeration(const std::string& name,
int boundary);
+// Get sparse histogram for enumerators.
+// |boundary| should be above the max enumerator sample.
+Histogram* SparseHistogramFactoryGetEnumeration(const std::string& name,
+ int boundary);
+
// Function for adding a |sample| to a histogram.
void HistogramAdd(Histogram* histogram_pointer, int sample);
diff --git a/system_wrappers/source/metrics_default.cc b/system_wrappers/source/metrics_default.cc
index fbb2956..7b62c81 100644
--- a/system_wrappers/source/metrics_default.cc
+++ b/system_wrappers/source/metrics_default.cc
@@ -247,6 +247,12 @@
return map->GetEnumerationHistogram(name, boundary);
}
+// Our default implementation reuses the non-sparse histogram.
+Histogram* SparseHistogramFactoryGetEnumeration(const std::string& name,
+ int boundary) {
+ return HistogramFactoryGetEnumeration(name, boundary);
+}
+
// Fast path. Adds |sample| to cached |histogram_pointer|.
void HistogramAdd(Histogram* histogram_pointer, int sample) {
RtcHistogram* ptr = reinterpret_cast<RtcHistogram*>(histogram_pointer);