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

Side by Side Diff: webrtc/modules/audio_processing/residual_echo_detector_complexity_unittest.cc

Issue 2568883004: Improvements to the reliability of the echo detector perf test. (Closed)
Patch Set: Introduced another const for the warmup batch size. Created 4 years 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 | « no previous file | 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
11 #include <numeric> 11 #include <numeric>
12 #include <vector> 12 #include <vector>
13 13
14 #include "webrtc/base/array_view.h" 14 #include "webrtc/base/array_view.h"
15 #include "webrtc/base/random.h" 15 #include "webrtc/base/random.h"
16 #include "webrtc/modules/audio_processing/audio_buffer.h" 16 #include "webrtc/modules/audio_processing/audio_buffer.h"
17 #include "webrtc/modules/audio_processing/include/audio_processing.h" 17 #include "webrtc/modules/audio_processing/include/audio_processing.h"
18 #include "webrtc/modules/audio_processing/residual_echo_detector.h" 18 #include "webrtc/modules/audio_processing/residual_echo_detector.h"
19 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h" 19 #include "webrtc/modules/audio_processing/test/audio_buffer_tools.h"
20 #include "webrtc/modules/audio_processing/test/performance_timer.h" 20 #include "webrtc/modules/audio_processing/test/performance_timer.h"
21 #include "webrtc/modules/audio_processing/test/simulator_buffers.h" 21 #include "webrtc/modules/audio_processing/test/simulator_buffers.h"
22 #include "webrtc/system_wrappers/include/clock.h" 22 #include "webrtc/system_wrappers/include/clock.h"
23 #include "webrtc/test/gtest.h" 23 #include "webrtc/test/gtest.h"
24 #include "webrtc/test/testsupport/perf_test.h" 24 #include "webrtc/test/testsupport/perf_test.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 namespace { 27 namespace {
28 28
29 const size_t kNumFramesToProcess = 100; 29 const size_t kNumFramesToProcess = 500;
30 const size_t kProcessingBatchSize = 20;
31 const size_t kWarmupBatchSize = 2 * kProcessingBatchSize;
30 const int kSampleRate = AudioProcessing::kSampleRate48kHz; 32 const int kSampleRate = AudioProcessing::kSampleRate48kHz;
31 const int kNumberOfChannels = 1; 33 const int kNumberOfChannels = 1;
32 34
33 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) { 35 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) {
34 std::string s = std::to_string(timer.GetDurationAverage()); 36 std::string s = std::to_string(timer.GetDurationAverage());
35 s += ", "; 37 s += ", ";
36 s += std::to_string(timer.GetDurationStandardDeviation()); 38 s += std::to_string(timer.GetDurationStandardDeviation());
37 return s; 39 return s;
38 } 40 }
39 41
40 void RunStandaloneSubmodule() { 42 void RunStandaloneSubmodule() {
41 test::SimulatorBuffers buffers( 43 test::SimulatorBuffers buffers(
42 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 44 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
43 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 45 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
44 test::PerformanceTimer timer(kNumFramesToProcess); 46 test::PerformanceTimer timer(kNumFramesToProcess);
45 47
46 ResidualEchoDetector echo_detector; 48 ResidualEchoDetector echo_detector;
47 echo_detector.Initialize(); 49 echo_detector.Initialize();
48 50
49 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 51 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
52 // The first batch of frames are for warming up, and are not part of the
53 // benchmark. After that the processing time is measured in chunks of
54 // kProcessingBatchSize frames.
55 if (frame_no >= kWarmupBatchSize && frame_no % kProcessingBatchSize == 0) {
56 timer.StartTimer();
57 }
58
50 buffers.UpdateInputBuffers(); 59 buffers.UpdateInputBuffers();
51
52 timer.StartTimer();
53 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>( 60 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>(
54 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 61 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
55 buffers.render_input_buffer->num_frames_per_band())); 62 buffers.render_input_buffer->num_frames_per_band()));
56 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>( 63 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>(
57 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 64 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
58 buffers.capture_input_buffer->num_frames_per_band())); 65 buffers.capture_input_buffer->num_frames_per_band()));
59 timer.StopTimer(); 66
67 if (frame_no >= kWarmupBatchSize &&
68 frame_no % kProcessingBatchSize == kProcessingBatchSize - 1) {
69 timer.StopTimer();
70 }
60 } 71 }
61 webrtc::test::PrintResultMeanAndError( 72 webrtc::test::PrintResultMeanAndError(
62 "echo_detector_call_durations", "", "StandaloneEchoDetector", 73 "echo_detector_call_durations", "", "StandaloneEchoDetector",
63 FormPerformanceMeasureString(timer), "us", false); 74 FormPerformanceMeasureString(timer), "us", false);
64 } 75 }
65 76
66 void RunTogetherWithApm(std::string test_description, 77 void RunTogetherWithApm(std::string test_description,
67 bool use_mobile_aec, 78 bool use_mobile_aec,
68 bool include_default_apm_processing) { 79 bool include_default_apm_processing) {
69 test::SimulatorBuffers buffers( 80 test::SimulatorBuffers buffers(
70 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 81 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
71 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 82 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
72 test::PerformanceTimer render_timer(kNumFramesToProcess); 83 test::PerformanceTimer timer(kNumFramesToProcess);
73 test::PerformanceTimer capture_timer(kNumFramesToProcess);
74 test::PerformanceTimer total_timer(kNumFramesToProcess);
75 84
76 webrtc::Config config; 85 webrtc::Config config;
77 AudioProcessing::Config apm_config; 86 AudioProcessing::Config apm_config;
78 if (include_default_apm_processing) { 87 if (include_default_apm_processing) {
79 config.Set<DelayAgnostic>(new DelayAgnostic(true)); 88 config.Set<DelayAgnostic>(new DelayAgnostic(true));
80 config.Set<ExtendedFilter>(new ExtendedFilter(true)); 89 config.Set<ExtendedFilter>(new ExtendedFilter(true));
81 } 90 }
82 apm_config.level_controller.enabled = include_default_apm_processing; 91 apm_config.level_controller.enabled = include_default_apm_processing;
83 apm_config.residual_echo_detector.enabled = true; 92 apm_config.residual_echo_detector.enabled = true;
84 93
(...skipping 20 matching lines...) Expand all
105 ASSERT_EQ(AudioProcessing::kNoError, 114 ASSERT_EQ(AudioProcessing::kNoError,
106 apm->noise_suppression()->Enable(include_default_apm_processing)); 115 apm->noise_suppression()->Enable(include_default_apm_processing));
107 ASSERT_EQ(AudioProcessing::kNoError, 116 ASSERT_EQ(AudioProcessing::kNoError,
108 apm->voice_detection()->Enable(include_default_apm_processing)); 117 apm->voice_detection()->Enable(include_default_apm_processing));
109 ASSERT_EQ(AudioProcessing::kNoError, 118 ASSERT_EQ(AudioProcessing::kNoError,
110 apm->level_estimator()->Enable(include_default_apm_processing)); 119 apm->level_estimator()->Enable(include_default_apm_processing));
111 120
112 StreamConfig stream_config(kSampleRate, kNumberOfChannels, false); 121 StreamConfig stream_config(kSampleRate, kNumberOfChannels, false);
113 122
114 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 123 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
124 // The first batch of frames are for warming up, and are not part of the
125 // benchmark. After that the processing time is measured in chunks of
126 // kProcessingBatchSize frames.
127 if (frame_no >= kWarmupBatchSize && frame_no % kProcessingBatchSize == 0) {
128 timer.StartTimer();
129 }
130
115 buffers.UpdateInputBuffers(); 131 buffers.UpdateInputBuffers();
116 132
117 total_timer.StartTimer();
118 render_timer.StartTimer();
119 ASSERT_EQ( 133 ASSERT_EQ(
120 AudioProcessing::kNoError, 134 AudioProcessing::kNoError,
121 apm->ProcessReverseStream(&buffers.render_input[0], stream_config, 135 apm->ProcessReverseStream(&buffers.render_input[0], stream_config,
122 stream_config, &buffers.render_output[0])); 136 stream_config, &buffers.render_output[0]));
123 137
124 render_timer.StopTimer();
125
126 capture_timer.StartTimer();
127 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0)); 138 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0));
128 if (include_default_apm_processing) { 139 if (include_default_apm_processing) {
129 apm->gain_control()->set_stream_analog_level(0); 140 apm->gain_control()->set_stream_analog_level(0);
130 if (!use_mobile_aec) { 141 if (!use_mobile_aec) {
131 apm->echo_cancellation()->set_stream_drift_samples(0); 142 apm->echo_cancellation()->set_stream_drift_samples(0);
132 } 143 }
133 } 144 }
134 ASSERT_EQ(AudioProcessing::kNoError, 145 ASSERT_EQ(AudioProcessing::kNoError,
135 apm->ProcessStream(&buffers.capture_input[0], stream_config, 146 apm->ProcessStream(&buffers.capture_input[0], stream_config,
136 stream_config, &buffers.capture_output[0])); 147 stream_config, &buffers.capture_output[0]));
137 148
138 capture_timer.StopTimer(); 149 if (frame_no >= kWarmupBatchSize &&
139 total_timer.StopTimer(); 150 frame_no % kProcessingBatchSize == kProcessingBatchSize - 1) {
151 timer.StopTimer();
152 }
140 } 153 }
141 154
142 webrtc::test::PrintResultMeanAndError( 155 webrtc::test::PrintResultMeanAndError(
143 "echo_detector_call_durations", "_render", test_description,
144 FormPerformanceMeasureString(render_timer), "us", false);
145 webrtc::test::PrintResultMeanAndError(
146 "echo_detector_call_durations", "_capture", test_description,
147 FormPerformanceMeasureString(capture_timer), "us", false);
148 webrtc::test::PrintResultMeanAndError(
149 "echo_detector_call_durations", "_total", test_description, 156 "echo_detector_call_durations", "_total", test_description,
150 FormPerformanceMeasureString(total_timer), "us", false); 157 FormPerformanceMeasureString(timer), "us", false);
151 } 158 }
152 159
153 } // namespace 160 } // namespace
154 161
155 TEST(EchoDetectorPerformanceTest, StandaloneProcessing) { 162 TEST(EchoDetectorPerformanceTest, StandaloneProcessing) {
156 RunStandaloneSubmodule(); 163 RunStandaloneSubmodule();
157 } 164 }
158 165
159 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) { 166 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) {
160 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false); 167 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false);
161 } 168 }
162 169
163 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) { 170 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) {
164 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true); 171 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true);
165 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true); 172 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true);
166 } 173 }
167 174
168 } // namespace webrtc 175 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698