diff --git a/system_wrappers/include/metrics.h b/system_wrappers/include/metrics.h index 13f2483b32..13ed2c936d 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* HistogramFactoryGetCountsLinear(const std::string& name, 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 fbb2956301..7b62c8103f 100644 --- a/system_wrappers/source/metrics_default.cc +++ b/system_wrappers/source/metrics_default.cc @@ -247,6 +247,12 @@ Histogram* HistogramFactoryGetEnumeration(const std::string& name, 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(histogram_pointer);