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

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: 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 int kSampleRate = AudioProcessing::kSampleRate48kHz; 30 const int kSampleRate = AudioProcessing::kSampleRate48kHz;
31 const int kNumberOfChannels = 1; 31 const int kNumberOfChannels = 1;
32 32
33 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) { 33 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) {
34 std::string s = std::to_string(timer.GetDurationAverage()); 34 std::string s = std::to_string(timer.GetDurationAverage());
35 s += ", "; 35 s += ", ";
36 s += std::to_string(timer.GetDurationStandardDeviation()); 36 s += std::to_string(timer.GetDurationStandardDeviation());
37 return s; 37 return s;
38 } 38 }
39 39
40 void RunStandaloneSubmodule() { 40 void RunStandaloneSubmodule() {
41 test::SimulatorBuffers buffers( 41 test::SimulatorBuffers buffers(
42 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 42 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
43 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 43 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
44 test::PerformanceTimer timer(kNumFramesToProcess); 44 test::PerformanceTimer timer(kNumFramesToProcess);
45 45
46 ResidualEchoDetector echo_detector; 46 ResidualEchoDetector echo_detector;
47 echo_detector.Initialize(); 47 echo_detector.Initialize();
48 48
49 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 49 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
50 // The first 20 frames are for warming up, and are not part of the
51 // benchmark. After that the processing time is measured in chunks of 20
52 // frames.
53 if (frame_no >= 20 && frame_no % 20 == 0) {
peah-webrtc 2016/12/14 09:00:04 You should probably add a constant (or 2) for the
ivoc 2016/12/14 09:46:42 Good idea, done.
54 timer.StartTimer();
55 }
56
50 buffers.UpdateInputBuffers(); 57 buffers.UpdateInputBuffers();
51
52 timer.StartTimer();
53 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>( 58 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>(
54 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 59 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
55 buffers.render_input_buffer->num_frames_per_band())); 60 buffers.render_input_buffer->num_frames_per_band()));
56 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>( 61 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>(
57 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 62 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
58 buffers.capture_input_buffer->num_frames_per_band())); 63 buffers.capture_input_buffer->num_frames_per_band()));
59 timer.StopTimer(); 64
65 if (frame_no >= 20 && frame_no % 20 == 19) {
peah-webrtc 2016/12/14 09:00:04 Please add a constant (or 2) for the 20s.
ivoc 2016/12/14 09:46:42 Done.
66 timer.StopTimer();
67 }
60 } 68 }
61 webrtc::test::PrintResultMeanAndError( 69 webrtc::test::PrintResultMeanAndError(
62 "echo_detector_call_durations", "", "StandaloneEchoDetector", 70 "echo_detector_call_durations", "", "StandaloneEchoDetector",
63 FormPerformanceMeasureString(timer), "us", false); 71 FormPerformanceMeasureString(timer), "us", false);
64 } 72 }
65 73
66 void RunTogetherWithApm(std::string test_description, 74 void RunTogetherWithApm(std::string test_description,
67 bool use_mobile_aec, 75 bool use_mobile_aec,
68 bool include_default_apm_processing) { 76 bool include_default_apm_processing) {
69 test::SimulatorBuffers buffers( 77 test::SimulatorBuffers buffers(
70 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 78 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
71 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 79 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
72 test::PerformanceTimer render_timer(kNumFramesToProcess); 80 test::PerformanceTimer timer(kNumFramesToProcess);
73 test::PerformanceTimer capture_timer(kNumFramesToProcess);
74 test::PerformanceTimer total_timer(kNumFramesToProcess);
75 81
76 webrtc::Config config; 82 webrtc::Config config;
77 AudioProcessing::Config apm_config; 83 AudioProcessing::Config apm_config;
78 if (include_default_apm_processing) { 84 if (include_default_apm_processing) {
79 config.Set<DelayAgnostic>(new DelayAgnostic(true)); 85 config.Set<DelayAgnostic>(new DelayAgnostic(true));
80 config.Set<ExtendedFilter>(new ExtendedFilter(true)); 86 config.Set<ExtendedFilter>(new ExtendedFilter(true));
81 } 87 }
82 apm_config.level_controller.enabled = include_default_apm_processing; 88 apm_config.level_controller.enabled = include_default_apm_processing;
83 apm_config.residual_echo_detector.enabled = true; 89 apm_config.residual_echo_detector.enabled = true;
84 90
(...skipping 20 matching lines...) Expand all
105 ASSERT_EQ(AudioProcessing::kNoError, 111 ASSERT_EQ(AudioProcessing::kNoError,
106 apm->noise_suppression()->Enable(include_default_apm_processing)); 112 apm->noise_suppression()->Enable(include_default_apm_processing));
107 ASSERT_EQ(AudioProcessing::kNoError, 113 ASSERT_EQ(AudioProcessing::kNoError,
108 apm->voice_detection()->Enable(include_default_apm_processing)); 114 apm->voice_detection()->Enable(include_default_apm_processing));
109 ASSERT_EQ(AudioProcessing::kNoError, 115 ASSERT_EQ(AudioProcessing::kNoError,
110 apm->level_estimator()->Enable(include_default_apm_processing)); 116 apm->level_estimator()->Enable(include_default_apm_processing));
111 117
112 StreamConfig stream_config(kSampleRate, kNumberOfChannels, false); 118 StreamConfig stream_config(kSampleRate, kNumberOfChannels, false);
113 119
114 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 120 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) {
121 // The first 20 frames are for warming up, and are not part of the
122 // benchmark. After that the processing time is measured in chunks of 20
123 // frames.
124 if (frame_no >= 20 && frame_no % 20 == 0) {
peah-webrtc 2016/12/14 09:00:04 Please add a constant (or 2) for the 20s.
ivoc 2016/12/14 09:46:42 Done.
125 timer.StartTimer();
126 }
127
115 buffers.UpdateInputBuffers(); 128 buffers.UpdateInputBuffers();
116 129
117 total_timer.StartTimer();
118 render_timer.StartTimer();
119 ASSERT_EQ( 130 ASSERT_EQ(
120 AudioProcessing::kNoError, 131 AudioProcessing::kNoError,
121 apm->ProcessReverseStream(&buffers.render_input[0], stream_config, 132 apm->ProcessReverseStream(&buffers.render_input[0], stream_config,
122 stream_config, &buffers.render_output[0])); 133 stream_config, &buffers.render_output[0]));
123 134
124 render_timer.StopTimer();
125
126 capture_timer.StartTimer();
127 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0)); 135 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0));
128 if (include_default_apm_processing) { 136 if (include_default_apm_processing) {
129 apm->gain_control()->set_stream_analog_level(0); 137 apm->gain_control()->set_stream_analog_level(0);
130 if (!use_mobile_aec) { 138 if (!use_mobile_aec) {
131 apm->echo_cancellation()->set_stream_drift_samples(0); 139 apm->echo_cancellation()->set_stream_drift_samples(0);
132 } 140 }
133 } 141 }
134 ASSERT_EQ(AudioProcessing::kNoError, 142 ASSERT_EQ(AudioProcessing::kNoError,
135 apm->ProcessStream(&buffers.capture_input[0], stream_config, 143 apm->ProcessStream(&buffers.capture_input[0], stream_config,
136 stream_config, &buffers.capture_output[0])); 144 stream_config, &buffers.capture_output[0]));
137 145
138 capture_timer.StopTimer(); 146 if (frame_no >= 20 && frame_no % 20 == 19) {
peah-webrtc 2016/12/14 09:00:04 Please add a constant (or 2) for the 20s.
ivoc 2016/12/14 09:46:42 Done.
139 total_timer.StopTimer(); 147 timer.StopTimer();
148 }
140 } 149 }
141 150
142 webrtc::test::PrintResultMeanAndError( 151 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, 152 "echo_detector_call_durations", "_total", test_description,
150 FormPerformanceMeasureString(total_timer), "us", false); 153 FormPerformanceMeasureString(timer), "us", false);
151 } 154 }
152 155
153 } // namespace 156 } // namespace
154 157
155 TEST(EchoDetectorPerformanceTest, StandaloneProcessing) { 158 TEST(EchoDetectorPerformanceTest, StandaloneProcessing) {
156 RunStandaloneSubmodule(); 159 RunStandaloneSubmodule();
157 } 160 }
158 161
159 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) { 162 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) {
160 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false); 163 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false);
161 } 164 }
162 165
163 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) { 166 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) {
164 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true); 167 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true);
165 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true); 168 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true);
166 } 169 }
167 170
168 } // namespace webrtc 171 } // 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