Adds AddSamples function to SamplesStatsCounter.
this allows merging two stats counter objects, will be used in a future CL to merge statistics for multiple video layers. Bug: webrtc:10365 Change-Id: Iee9c48b68dfd7ba29537c14fc5f4a7c1c333d145 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131942 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Yves Gerey <yvesg@google.com> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27534}
This commit is contained in:
parent
7a930da66b
commit
d93a004086
@ -38,6 +38,16 @@ void SamplesStatsCounter::AddSample(double value) {
|
||||
sum_squared_ += value * value;
|
||||
}
|
||||
|
||||
void SamplesStatsCounter::AddSamples(const SamplesStatsCounter& other) {
|
||||
for (double sample : other.samples_)
|
||||
samples_.push_back(sample);
|
||||
sorted_ = false;
|
||||
max_ = std::max(max_, other.max_);
|
||||
min_ = std::min(min_, other.min_);
|
||||
sum_ += other.sum_;
|
||||
sum_squared_ += other.sum_squared_;
|
||||
}
|
||||
|
||||
double SamplesStatsCounter::GetPercentile(double percentile) {
|
||||
RTC_DCHECK(!IsEmpty());
|
||||
RTC_CHECK_GE(percentile, 0);
|
||||
|
||||
@ -31,6 +31,9 @@ class SamplesStatsCounter {
|
||||
// Adds sample to the stats in amortized O(1) time.
|
||||
void AddSample(double value);
|
||||
|
||||
// Adds samples from another counter.
|
||||
void AddSamples(const SamplesStatsCounter& other);
|
||||
|
||||
// Returns if there are any values in O(1) time.
|
||||
bool IsEmpty() const { return samples_.empty(); }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user