From 89eaf16701b1f1e18d80e4752004a9b4b54531f3 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Thu, 25 Apr 2019 12:23:40 +0200 Subject: [PATCH] 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 Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#27762} --- rtc_base/BUILD.gn | 1 + rtc_base/numerics/samples_stats_counter.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index e7ad807335..fc3a3f39d5 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -603,6 +603,7 @@ rtc_static_library("rtc_numerics") { ":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 ac5f12cdea..43c58c7c32 100644 --- a/rtc_base/numerics/samples_stats_counter.h +++ b/rtc_base/numerics/samples_stats_counter.h @@ -13,6 +13,7 @@ #include +#include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/running_statistics.h" @@ -75,6 +76,11 @@ class SamplesStatsCounter { // |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 GetSamples() const { return samples_; } private: RunningStatistics stats_;