Add API to get added samples from SamplesStatsCounter
Bug: webrtc:10138
Change-Id: Idf283309b5323d1cb7484bffdf400d62c80a88d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133566
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27762}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index e7ad807..fc3a3f3 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -603,6 +603,7 @@
":checks",
":rtc_base_approved",
":safe_compare",
+ "../api:array_view",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/types:optional",
]
diff --git a/rtc_base/numerics/samples_stats_counter.h b/rtc_base/numerics/samples_stats_counter.h
index ac5f12c..43c58c7 100644
--- a/rtc_base/numerics/samples_stats_counter.h
+++ b/rtc_base/numerics/samples_stats_counter.h
@@ -13,6 +13,7 @@
#include <vector>
+#include "api/array_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/numerics/running_statistics.h"
@@ -75,6 +76,11 @@
// |percentile| has to be in [0; 1]. 0 percentile is the min in the array and
// 1 percentile is the max in the array.
double GetPercentile(double percentile);
+ // Returns array view with all samples added into counter. There are no
+ // guarantees of order, so samples can be in different order comparing to in
+ // which they were added into counter. Also return value will be invalidate
+ // after call to any non const method.
+ rtc::ArrayView<const double> GetSamples() const { return samples_; }
private:
RunningStatistics<double> stats_;