diff --git a/webrtc/system_wrappers/include/metrics.h b/webrtc/system_wrappers/include/metrics.h index 9b14736ec2..25a51807de 100644 --- a/webrtc/system_wrappers/include/metrics.h +++ b/webrtc/system_wrappers/include/metrics.h @@ -85,6 +85,11 @@ RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ webrtc::metrics::HistogramFactoryGetCounts(name, min, max, bucket_count)) +#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \ + RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \ + webrtc::metrics::HistogramFactoryGetCountsLinear( \ + name, min, max, bucket_count)) + // Deprecated. // TODO(asapersson): Remove. #define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \ @@ -213,6 +218,12 @@ class Histogram; Histogram* HistogramFactoryGetCounts( const std::string& name, int min, int max, int bucket_count); +// Get histogram for counters with linear bucket spacing. +Histogram* HistogramFactoryGetCountsLinear(const std::string& name, + int min, + int max, + int bucket_count); + // Get histogram for enumerators. // |boundary| should be above the max enumerator sample. Histogram* HistogramFactoryGetEnumeration( diff --git a/webrtc/system_wrappers/source/metrics_default.cc b/webrtc/system_wrappers/source/metrics_default.cc index d7d24fa50d..6ca90dafdc 100644 --- a/webrtc/system_wrappers/source/metrics_default.cc +++ b/webrtc/system_wrappers/source/metrics_default.cc @@ -213,6 +213,19 @@ Histogram* HistogramFactoryGetCounts(const std::string& name, int min, int max, int bucket_count) { + // TODO(asapersson): Alternative implementation will be needed if this + // histogram type should be truly exponential. + return HistogramFactoryGetCountsLinear(name, min, max, bucket_count); +} + +// Histogram with linearly spaced buckets. +// Creates (or finds) histogram. +// The returned histogram pointer is cached (and used for adding samples in +// subsequent calls). +Histogram* HistogramFactoryGetCountsLinear(const std::string& name, + int min, + int max, + int bucket_count) { RtcHistogramMap* map = GetMap(); if (!map) return nullptr;