Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1709)

Unified Diff: webrtc/modules/audio_processing/test/performance_timer.cc

Issue 2750413002: Improve stability of the echo detector complexity perf tests. (Closed)
Patch Set: Changed int to size_t. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_processing/test/performance_timer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/test/performance_timer.cc
diff --git a/webrtc/modules/audio_processing/test/performance_timer.cc b/webrtc/modules/audio_processing/test/performance_timer.cc
index c4fcc0a7123feece4689dbd0f2ec211c5ef50be2..a002fe35a07548b4673f8c5dedde51278f8e2913 100644
--- a/webrtc/modules/audio_processing/test/performance_timer.cc
+++ b/webrtc/modules/audio_processing/test/performance_timer.cc
@@ -36,23 +36,39 @@ void PerformanceTimer::StopTimer() {
}
double PerformanceTimer::GetDurationAverage() const {
- RTC_DCHECK(!timestamps_us_.empty());
- return static_cast<double>(
- std::accumulate(timestamps_us_.begin(), timestamps_us_.end(), 0)) /
- timestamps_us_.size();
+ return GetDurationAverage(0);
}
double PerformanceTimer::GetDurationStandardDeviation() const {
- RTC_DCHECK(!timestamps_us_.empty());
- double average_duration = GetDurationAverage();
+ return GetDurationStandardDeviation(0);
+}
+
+double PerformanceTimer::GetDurationAverage(
+ size_t number_of_warmup_samples) const {
+ RTC_DCHECK_GT(timestamps_us_.size(), number_of_warmup_samples);
+ const size_t number_of_samples =
+ timestamps_us_.size() - number_of_warmup_samples;
+ return static_cast<double>(
+ std::accumulate(timestamps_us_.begin() + number_of_warmup_samples,
+ timestamps_us_.end(), static_cast<int64_t>(0))) /
+ number_of_samples;
+}
+
+double PerformanceTimer::GetDurationStandardDeviation(
+ size_t number_of_warmup_samples) const {
+ RTC_DCHECK_GT(timestamps_us_.size(), number_of_warmup_samples);
+ const size_t number_of_samples =
+ timestamps_us_.size() - number_of_warmup_samples;
+ RTC_DCHECK_GT(number_of_samples, 0);
+ double average_duration = GetDurationAverage(number_of_warmup_samples);
double variance = std::accumulate(
- timestamps_us_.begin(), timestamps_us_.end(), 0.0,
- [average_duration](const double& a, const int64_t& b) {
+ timestamps_us_.begin() + number_of_warmup_samples, timestamps_us_.end(),
+ 0.0, [average_duration](const double& a, const int64_t& b) {
return a + (b - average_duration) * (b - average_duration);
});
- return sqrt(variance / timestamps_us_.size());
+ return sqrt(variance / number_of_samples);
}
} // namespace test
« no previous file with comments | « webrtc/modules/audio_processing/test/performance_timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698