From d3fabe51b201761b3959d612eab4577f0c2a88e1 Mon Sep 17 00:00:00 2001 From: terelius Date: Wed, 18 Jan 2017 01:59:53 -0800 Subject: [PATCH] Improve computational performance of BWE by switching list to deque. BUG=webrtc:6998 Review-Url: https://codereview.webrtc.org/2633293004 Cr-Commit-Position: refs/heads/master@{#16137} --- .../modules/congestion_controller/median_slope_estimator.h | 4 ++-- webrtc/modules/congestion_controller/trendline_estimator.cc | 2 +- webrtc/modules/congestion_controller/trendline_estimator.h | 4 ++-- webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc | 5 ++--- webrtc/modules/remote_bitrate_estimator/overuse_estimator.h | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/webrtc/modules/congestion_controller/median_slope_estimator.h b/webrtc/modules/congestion_controller/median_slope_estimator.h index c36fdbeff0..3a13ec71ab 100644 --- a/webrtc/modules/congestion_controller/median_slope_estimator.h +++ b/webrtc/modules/congestion_controller/median_slope_estimator.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include "webrtc/base/constructormagic.h" @@ -63,7 +63,7 @@ class MedianSlopeEstimator { unsigned int num_of_deltas_; // Theil-Sen robust line fitting double accumulated_delay_; - std::list delay_hist_; + std::deque delay_hist_; PercentileFilter median_filter_; double trendline_; diff --git a/webrtc/modules/congestion_controller/trendline_estimator.cc b/webrtc/modules/congestion_controller/trendline_estimator.cc index ad05a64e1e..6edcd8182d 100644 --- a/webrtc/modules/congestion_controller/trendline_estimator.cc +++ b/webrtc/modules/congestion_controller/trendline_estimator.cc @@ -20,7 +20,7 @@ namespace webrtc { namespace { rtc::Optional LinearFitSlope( - const std::list> points) { + const std::deque>& points) { RTC_DCHECK(points.size() >= 2); // Compute the "center of mass". double sum_x = 0; diff --git a/webrtc/modules/congestion_controller/trendline_estimator.h b/webrtc/modules/congestion_controller/trendline_estimator.h index 7ca9b7d072..f09ccb5629 100644 --- a/webrtc/modules/congestion_controller/trendline_estimator.h +++ b/webrtc/modules/congestion_controller/trendline_estimator.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include "webrtc/base/constructormagic.h" @@ -61,7 +61,7 @@ class TrendlineEstimator { double accumulated_delay_; double smoothed_delay_; // Linear least squares regression. - std::list> delay_hist_; + std::deque> delay_hist_; double trendline_; RTC_DISALLOW_COPY_AND_ASSIGN(TrendlineEstimator); diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc index 54e73d972b..85efecd02c 100644 --- a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc +++ b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc @@ -129,9 +129,8 @@ double OveruseEstimator::UpdateMinFramePeriod(double ts_delta) { if (ts_delta_hist_.size() >= kMinFramePeriodHistoryLength) { ts_delta_hist_.pop_front(); } - std::list::iterator it = ts_delta_hist_.begin(); - for (; it != ts_delta_hist_.end(); it++) { - min_frame_period = std::min(*it, min_frame_period); + for (const double old_ts_delta : ts_delta_hist_) { + min_frame_period = std::min(old_ts_delta, min_frame_period); } ts_delta_hist_.push_back(ts_delta); return min_frame_period; diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.h b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.h index dd8efaadc1..895ed77716 100644 --- a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.h +++ b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.h @@ -10,7 +10,7 @@ #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_OVERUSE_ESTIMATOR_H_ -#include +#include #include "webrtc/base/constructormagic.h" #include "webrtc/common_types.h" @@ -64,7 +64,7 @@ class OveruseEstimator { double process_noise_[2]; double avg_noise_; double var_noise_; - std::list ts_delta_hist_; + std::deque ts_delta_hist_; RTC_DISALLOW_COPY_AND_ASSIGN(OveruseEstimator); };