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}
This commit is contained in:
Qingsi Wang
2018-06-26 12:30:04 -07:00
committed by Commit Bot
parent 901e0ffc33
commit d6eb71ef2c
2 changed files with 13 additions and 2 deletions

View File

@ -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);

View File

@ -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<RtcHistogram*>(histogram_pointer);