Chromium Code Reviews| 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..489ce12e75483dafc857395aaf9d21601f5b3d0b 100644 |
| --- a/webrtc/modules/audio_processing/test/performance_timer.cc |
| +++ b/webrtc/modules/audio_processing/test/performance_timer.cc |
| @@ -36,23 +36,38 @@ 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( |
| + int number_of_warmup_samples) const { |
|
hlundin-webrtc
2017/03/17 14:16:37
This should be a size_t, imo.
ivoc
2017/03/17 15:14:47
Done.
|
| + const int number_of_samples = |
|
hlundin-webrtc
2017/03/17 14:16:37
RTC_DCHECK_GT(timestamps_us_.size(), number_of_war
ivoc
2017/03/17 15:14:47
Done.
|
| + timestamps_us_.size() - number_of_warmup_samples; |
| + RTC_DCHECK_GT(number_of_samples, 0); |
|
hlundin-webrtc
2017/03/17 14:16:36
... and skip this.
ivoc
2017/03/17 15:14:47
Done.
|
| + return static_cast<double>( |
| + std::accumulate(timestamps_us_.begin() + number_of_warmup_samples, |
| + timestamps_us_.end(), 0)) / |
|
hlundin-webrtc
2017/03/17 14:16:37
Is it a problem that the initial value is an int l
ivoc
2017/03/17 15:14:47
Hmm, I think it makes sense to use int64_t's for t
|
| + number_of_samples; |
| +} |
| + |
| +double PerformanceTimer::GetDurationStandardDeviation( |
|
hlundin-webrtc
2017/03/17 14:16:36
Essentially the same comments as above.
ivoc
2017/03/17 15:14:47
Done.
|
| + int number_of_warmup_samples) const { |
| + const int 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( |
|
ivoc
2017/03/17 15:14:47
I used the same pattern of accumulating in int64_t
ivoc
2017/03/17 15:16:35
Oh, oops, that seems like a bad idea on second tho
|
| - 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 |