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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_processing/test/performance_timer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 void PerformanceTimer::StartTimer() { 29 void PerformanceTimer::StartTimer() {
30 start_timestamp_us_ = rtc::Optional<int64_t>(clock_->TimeInMicroseconds()); 30 start_timestamp_us_ = rtc::Optional<int64_t>(clock_->TimeInMicroseconds());
31 } 31 }
32 32
33 void PerformanceTimer::StopTimer() { 33 void PerformanceTimer::StopTimer() {
34 RTC_DCHECK(start_timestamp_us_); 34 RTC_DCHECK(start_timestamp_us_);
35 timestamps_us_.push_back(clock_->TimeInMicroseconds() - *start_timestamp_us_); 35 timestamps_us_.push_back(clock_->TimeInMicroseconds() - *start_timestamp_us_);
36 } 36 }
37 37
38 double PerformanceTimer::GetDurationAverage() const { 38 double PerformanceTimer::GetDurationAverage() const {
39 RTC_DCHECK(!timestamps_us_.empty()); 39 return GetDurationAverage(0);
40 return static_cast<double>(
41 std::accumulate(timestamps_us_.begin(), timestamps_us_.end(), 0)) /
42 timestamps_us_.size();
43 } 40 }
44 41
45 double PerformanceTimer::GetDurationStandardDeviation() const { 42 double PerformanceTimer::GetDurationStandardDeviation() const {
46 RTC_DCHECK(!timestamps_us_.empty()); 43 return GetDurationStandardDeviation(0);
47 double average_duration = GetDurationAverage(); 44 }
45
46 double PerformanceTimer::GetDurationAverage(
47 size_t number_of_warmup_samples) const {
48 RTC_DCHECK_GT(timestamps_us_.size(), number_of_warmup_samples);
49 const size_t number_of_samples =
50 timestamps_us_.size() - number_of_warmup_samples;
51 return static_cast<double>(
52 std::accumulate(timestamps_us_.begin() + number_of_warmup_samples,
53 timestamps_us_.end(), static_cast<int64_t>(0))) /
54 number_of_samples;
55 }
56
57 double PerformanceTimer::GetDurationStandardDeviation(
58 size_t number_of_warmup_samples) const {
59 RTC_DCHECK_GT(timestamps_us_.size(), number_of_warmup_samples);
60 const size_t number_of_samples =
61 timestamps_us_.size() - number_of_warmup_samples;
62 RTC_DCHECK_GT(number_of_samples, 0);
63 double average_duration = GetDurationAverage(number_of_warmup_samples);
48 64
49 double variance = std::accumulate( 65 double variance = std::accumulate(
50 timestamps_us_.begin(), timestamps_us_.end(), 0.0, 66 timestamps_us_.begin() + number_of_warmup_samples, timestamps_us_.end(),
51 [average_duration](const double& a, const int64_t& b) { 67 0.0, [average_duration](const double& a, const int64_t& b) {
52 return a + (b - average_duration) * (b - average_duration); 68 return a + (b - average_duration) * (b - average_duration);
53 }); 69 });
54 70
55 return sqrt(variance / timestamps_us_.size()); 71 return sqrt(variance / number_of_samples);
56 } 72 }
57 73
58 } // namespace test 74 } // namespace test
59 } // namespace webrtc 75 } // namespace webrtc
OLDNEW
« 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