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

Side by Side Diff: webrtc/modules/audio_processing/level_controller/level_controller_complexity_unittest.cc

Issue 2549403002: Robustifying and simplifying the level controller complexity tests (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/level_controller/level_controller.h" 18 #include "webrtc/modules/audio_processing/level_controller/level_controller.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/bitexactness_tools.h" 20 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h"
21 #include "webrtc/modules/audio_processing/test/performance_timer.h" 21 #include "webrtc/modules/audio_processing/test/performance_timer.h"
22 #include "webrtc/modules/audio_processing/test/simulator_buffers.h" 22 #include "webrtc/modules/audio_processing/test/simulator_buffers.h"
23 #include "webrtc/system_wrappers/include/clock.h" 23 #include "webrtc/system_wrappers/include/clock.h"
24 #include "webrtc/test/gtest.h" 24 #include "webrtc/test/gtest.h"
25 #include "webrtc/test/testsupport/perf_test.h" 25 #include "webrtc/test/testsupport/perf_test.h"
26 26
27 namespace webrtc { 27 namespace webrtc {
28 namespace { 28 namespace {
29 29
30 const size_t kNumFramesToProcess = 100; 30 const size_t kNumFramesToProcess = 300;
31 const size_t kNumFramesToProcessAtWarmup = 300;
32 const size_t kToTalNumFrames =
33 kNumFramesToProcess + kNumFramesToProcessAtWarmup;
31 34
32 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) { 35 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) {
33 std::string s = std::to_string(timer.GetDurationAverage()); 36 std::string s = std::to_string(timer.GetDurationAverage());
34 s += ", "; 37 s += ", ";
35 s += std::to_string(timer.GetDurationStandardDeviation()); 38 s += std::to_string(timer.GetDurationStandardDeviation());
36 return s; 39 return s;
37 } 40 }
38 41
39 void RunStandaloneSubmodule(int sample_rate_hz, size_t num_channels) { 42 void RunStandaloneSubmodule(int sample_rate_hz, size_t num_channels) {
40 test::SimulatorBuffers buffers(sample_rate_hz, sample_rate_hz, sample_rate_hz, 43 test::SimulatorBuffers buffers(sample_rate_hz, sample_rate_hz, sample_rate_hz,
41 sample_rate_hz, num_channels, num_channels, 44 sample_rate_hz, num_channels, num_channels,
42 num_channels, num_channels); 45 num_channels, num_channels);
43 test::PerformanceTimer timer(kNumFramesToProcess); 46 test::PerformanceTimer timer(kNumFramesToProcess);
44 47
45 LevelController level_controller; 48 LevelController level_controller;
46 level_controller.Initialize(sample_rate_hz); 49 level_controller.Initialize(sample_rate_hz);
47 50
48 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 51 for (size_t frame_no = 0; frame_no < kToTalNumFrames; ++frame_no) {
49 buffers.UpdateInputBuffers(); 52 buffers.UpdateInputBuffers();
50 53
51 timer.StartTimer(); 54 if (frame_no >= kNumFramesToProcessAtWarmup) {
55 timer.StartTimer();
56 }
52 level_controller.Process(buffers.capture_input_buffer.get()); 57 level_controller.Process(buffers.capture_input_buffer.get());
53 timer.StopTimer(); 58 if (frame_no >= kNumFramesToProcessAtWarmup) {
59 timer.StopTimer();
60 }
54 } 61 }
55 webrtc::test::PrintResultMeanAndError( 62 webrtc::test::PrintResultMeanAndError(
56 "level_controller_call_durations", 63 "level_controller_call_durations",
57 "_" + std::to_string(sample_rate_hz) + "Hz_" + 64 "_" + std::to_string(sample_rate_hz) + "Hz_" +
58 std::to_string(num_channels) + "_channels", 65 std::to_string(num_channels) + "_channels",
59 "StandaloneLevelControl", FormPerformanceMeasureString(timer), "us", 66 "StandaloneLevelControl", FormPerformanceMeasureString(timer), "us",
60 false); 67 false);
61 } 68 }
62 69
63 void RunTogetherWithApm(std::string test_description, 70 void RunTogetherWithApm(std::string test_description,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 120
114 StreamConfig render_input_config(render_input_sample_rate_hz, num_channels, 121 StreamConfig render_input_config(render_input_sample_rate_hz, num_channels,
115 false); 122 false);
116 StreamConfig render_output_config(render_output_sample_rate_hz, num_channels, 123 StreamConfig render_output_config(render_output_sample_rate_hz, num_channels,
117 false); 124 false);
118 StreamConfig capture_input_config(capture_input_sample_rate_hz, num_channels, 125 StreamConfig capture_input_config(capture_input_sample_rate_hz, num_channels,
119 false); 126 false);
120 StreamConfig capture_output_config(capture_output_sample_rate_hz, 127 StreamConfig capture_output_config(capture_output_sample_rate_hz,
121 num_channels, false); 128 num_channels, false);
122 129
123 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 130 for (size_t frame_no = 0; frame_no < kToTalNumFrames; ++frame_no) {
124 buffers.UpdateInputBuffers(); 131 buffers.UpdateInputBuffers();
125 132
126 total_timer.StartTimer(); 133 if (frame_no >= kNumFramesToProcessAtWarmup) {
127 render_timer.StartTimer(); 134 total_timer.StartTimer();
135 render_timer.StartTimer();
136 }
128 ASSERT_EQ(AudioProcessing::kNoError, 137 ASSERT_EQ(AudioProcessing::kNoError,
129 apm->ProcessReverseStream( 138 apm->ProcessReverseStream(
130 &buffers.render_input[0], render_input_config, 139 &buffers.render_input[0], render_input_config,
131 render_output_config, &buffers.render_output[0])); 140 render_output_config, &buffers.render_output[0]));
132 141
133 render_timer.StopTimer(); 142 if (frame_no >= kNumFramesToProcessAtWarmup) {
143 render_timer.StopTimer();
134 144
135 capture_timer.StartTimer(); 145 capture_timer.StartTimer();
146 }
147
136 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0)); 148 ASSERT_EQ(AudioProcessing::kNoError, apm->set_stream_delay_ms(0));
137 ASSERT_EQ( 149 ASSERT_EQ(
138 AudioProcessing::kNoError, 150 AudioProcessing::kNoError,
139 apm->ProcessStream(&buffers.capture_input[0], capture_input_config, 151 apm->ProcessStream(&buffers.capture_input[0], capture_input_config,
140 capture_output_config, &buffers.capture_output[0])); 152 capture_output_config, &buffers.capture_output[0]));
141 153
142 capture_timer.StopTimer(); 154 if (frame_no >= kNumFramesToProcessAtWarmup) {
143 total_timer.StopTimer(); 155 capture_timer.StopTimer();
156 total_timer.StopTimer();
157 }
144 } 158 }
145 159
146 webrtc::test::PrintResultMeanAndError( 160 webrtc::test::PrintResultMeanAndError(
147 "level_controller_call_durations", 161 "level_controller_call_durations",
148 "_" + std::to_string(render_input_sample_rate_hz) + "_" + 162 "_" + std::to_string(render_input_sample_rate_hz) + "_" +
149 std::to_string(render_output_sample_rate_hz) + "_" + 163 std::to_string(render_output_sample_rate_hz) + "_" +
150 std::to_string(capture_input_sample_rate_hz) + "_" + 164 std::to_string(capture_input_sample_rate_hz) + "_" +
151 std::to_string(capture_output_sample_rate_hz) + "Hz_" + 165 std::to_string(capture_output_sample_rate_hz) + "Hz_" +
152 std::to_string(num_channels) + "_channels" + "_render", 166 std::to_string(num_channels) + "_channels" + "_render",
153 test_description, FormPerformanceMeasureString(render_timer), "us", 167 test_description, FormPerformanceMeasureString(render_timer), "us",
(...skipping 28 matching lines...) Expand all
182 RunStandaloneSubmodule(sample_rate, num_channels); 196 RunStandaloneSubmodule(sample_rate, num_channels);
183 } 197 }
184 } 198 }
185 } 199 }
186 200
187 void TestSomeSampleRatesWithApm(const std::string& test_name, 201 void TestSomeSampleRatesWithApm(const std::string& test_name,
188 bool use_mobile_agc, 202 bool use_mobile_agc,
189 bool include_default_apm_processing) { 203 bool include_default_apm_processing) {
190 // Test some stereo combinations first. 204 // Test some stereo combinations first.
191 size_t num_channels = 2; 205 size_t num_channels = 2;
192 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate8kHz,
193 AudioProcessing::kSampleRate48kHz, num_channels,
194 use_mobile_agc, include_default_apm_processing);
195 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate16kHz, 206 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate16kHz,
196 AudioProcessing::kSampleRate32kHz, num_channels, 207 AudioProcessing::kSampleRate32kHz, num_channels,
197 use_mobile_agc, include_default_apm_processing); 208 use_mobile_agc, include_default_apm_processing);
198 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate32kHz,
199 AudioProcessing::kSampleRate16kHz, num_channels,
200 use_mobile_agc, include_default_apm_processing);
201 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate48kHz, 209 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate48kHz,
202 AudioProcessing::kSampleRate8kHz, num_channels, 210 AudioProcessing::kSampleRate8kHz, num_channels,
203 use_mobile_agc, include_default_apm_processing); 211 use_mobile_agc, include_default_apm_processing);
204 RunTogetherWithApm(test_name, 48000, 48000, 44100, 44100, num_channels, 212 RunTogetherWithApm(test_name, 48000, 48000, 44100, 44100, num_channels,
205 use_mobile_agc, include_default_apm_processing); 213 use_mobile_agc, include_default_apm_processing);
206 214
207 // Then test mono combinations. 215 // Then test mono combinations.
208 num_channels = 1; 216 num_channels = 1;
209 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate48kHz, 217 RunTogetherWithApm(test_name, 48000, 48000, AudioProcessing::kSampleRate48kHz,
210 AudioProcessing::kSampleRate48kHz, num_channels, 218 AudioProcessing::kSampleRate48kHz, num_channels,
(...skipping 15 matching lines...) Expand all
226 TEST(LevelControllerPerformanceTest, DISABLED_InteractionWithDefaultApm) { 234 TEST(LevelControllerPerformanceTest, DISABLED_InteractionWithDefaultApm) {
227 #endif 235 #endif
228 bool include_default_apm_processing = true; 236 bool include_default_apm_processing = true;
229 TestSomeSampleRatesWithApm("LevelControlAndDefaultDesktopApm", false, 237 TestSomeSampleRatesWithApm("LevelControlAndDefaultDesktopApm", false,
230 include_default_apm_processing); 238 include_default_apm_processing);
231 TestSomeSampleRatesWithApm("LevelControlAndDefaultMobileApm", true, 239 TestSomeSampleRatesWithApm("LevelControlAndDefaultMobileApm", true,
232 include_default_apm_processing); 240 include_default_apm_processing);
233 } 241 }
234 242
235 } // namespace webrtc 243 } // 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