From d6eb71ef2ca42e5eeaf1a1ace8ec5fb065cd1000 Mon Sep 17 00:00:00 2001 From: Qingsi Wang Date: Tue, 26 Jun 2018 12:30:04 -0700 Subject: [PATCH] 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 Commit-Queue: Qingsi Wang Cr-Commit-Position: refs/heads/master@{#23750} --- system_wrappers/include/metrics.h | 9 +++++++-- system_wrappers/source/metrics_default.cc | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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);