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

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

Issue 2750413002: Improve stability of the echo detector complexity perf tests. (Closed)
Patch Set: 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 | « 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 = 500; 29 const size_t kNumFramesToProcess = 20000;
hlundin-webrtc 2017/03/17 08:48:03 Nit: constexprs, please.
ivoc 2017/03/17 13:53:20 Done.
30 const size_t kProcessingBatchSize = 20; 30 const size_t kNumFramesToProcessStandalone = 50 * kNumFramesToProcess;
31 const size_t kWarmupBatchSize = 2 * kProcessingBatchSize; 31 const size_t kProcessingBatchSize = 300;
32 const size_t kProcessingBatchSizeStandalone = 50 * kProcessingBatchSize;
33 const size_t kWarmupBatchSize = 50 * kProcessingBatchSize;
34 const size_t kWarmupBatchSizeStandalone = 50 * kWarmupBatchSize;
32 const int kSampleRate = AudioProcessing::kSampleRate48kHz; 35 const int kSampleRate = AudioProcessing::kSampleRate48kHz;
33 const int kNumberOfChannels = 1; 36 const int kNumberOfChannels = 1;
34 37
35 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) { 38 std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) {
36 std::string s = std::to_string(timer.GetDurationAverage()); 39 std::string s = std::to_string(timer.GetDurationAverage());
37 s += ", "; 40 s += ", ";
38 s += std::to_string(timer.GetDurationStandardDeviation()); 41 s += std::to_string(timer.GetDurationStandardDeviation());
39 return s; 42 return s;
40 } 43 }
41 44
42 void RunStandaloneSubmodule() { 45 void RunStandaloneSubmodule() {
43 test::SimulatorBuffers buffers( 46 test::SimulatorBuffers buffers(
44 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 47 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
45 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 48 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
46 test::PerformanceTimer timer(kNumFramesToProcess); 49 test::PerformanceTimer timer(kNumFramesToProcessStandalone /
hlundin-webrtc 2017/03/17 08:48:03 I suggest you modify PerformanceTimer to help you
ivoc 2017/03/17 13:53:20 Good idea. I implemented it in a bit of a differen
hlundin-webrtc 2017/03/17 14:16:36 Good solution!
50 kProcessingBatchSizeStandalone);
47 51
48 ResidualEchoDetector echo_detector; 52 ResidualEchoDetector echo_detector;
49 echo_detector.Initialize(); 53 echo_detector.Initialize();
54 float sum = 0.f;
50 55
51 for (size_t frame_no = 0; frame_no < kNumFramesToProcess; ++frame_no) { 56 for (size_t frame_no = 0; frame_no < kNumFramesToProcessStandalone;
57 ++frame_no) {
52 // The first batch of frames are for warming up, and are not part of the 58 // 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 59 // benchmark. After that the processing time is measured in chunks of
54 // kProcessingBatchSize frames. 60 // kProcessingBatchSize frames.
55 if (frame_no >= kWarmupBatchSize && frame_no % kProcessingBatchSize == 0) { 61 if (frame_no >= kWarmupBatchSizeStandalone &&
62 frame_no % kProcessingBatchSizeStandalone == 0) {
hlundin-webrtc 2017/03/17 08:48:03 I don't know if this will skew the measurement, bu
ivoc 2017/03/17 13:53:20 Although I agree that modulo operations are pretty
hlundin-webrtc 2017/03/17 14:16:36 Acknowledged.
56 timer.StartTimer(); 63 timer.StartTimer();
57 } 64 }
58 65
59 buffers.UpdateInputBuffers(); 66 buffers.UpdateInputBuffers();
60 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>( 67 echo_detector.AnalyzeRenderAudio(rtc::ArrayView<const float>(
61 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 68 buffers.render_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
62 buffers.render_input_buffer->num_frames_per_band())); 69 buffers.render_input_buffer->num_frames_per_band()));
63 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>( 70 echo_detector.AnalyzeCaptureAudio(rtc::ArrayView<const float>(
64 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz], 71 buffers.capture_input_buffer->split_bands_const_f(0)[kBand0To8kHz],
65 buffers.capture_input_buffer->num_frames_per_band())); 72 buffers.capture_input_buffer->num_frames_per_band()));
73 sum += echo_detector.echo_likelihood();
66 74
67 if (frame_no >= kWarmupBatchSize && 75 if (frame_no >= kWarmupBatchSizeStandalone &&
68 frame_no % kProcessingBatchSize == kProcessingBatchSize - 1) { 76 frame_no % kProcessingBatchSizeStandalone ==
77 kProcessingBatchSizeStandalone - 1) {
69 timer.StopTimer(); 78 timer.StopTimer();
70 } 79 }
71 } 80 }
81 EXPECT_EQ(0.0f, sum);
hlundin-webrtc 2017/03/17 08:48:03 Do we know that this will be exactly 0.0? Are ther
ivoc 2017/03/17 13:53:20 In this test both signals are filled with zeros, s
hlundin-webrtc 2017/03/17 14:16:36 Acknowledged.
72 webrtc::test::PrintResultMeanAndError( 82 webrtc::test::PrintResultMeanAndError(
73 "echo_detector_call_durations", "", "StandaloneEchoDetector", 83 "echo_detector_call_durations", "", "StandaloneEchoDetector",
74 FormPerformanceMeasureString(timer), "us", false); 84 FormPerformanceMeasureString(timer), "us", false);
75 } 85 }
76 86
77 void RunTogetherWithApm(std::string test_description, 87 void RunTogetherWithApm(std::string test_description,
78 bool use_mobile_aec, 88 bool use_mobile_aec,
79 bool include_default_apm_processing) { 89 bool include_default_apm_processing) {
80 test::SimulatorBuffers buffers( 90 test::SimulatorBuffers buffers(
81 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, 91 kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels,
82 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels); 92 kNumberOfChannels, kNumberOfChannels, kNumberOfChannels);
83 test::PerformanceTimer timer(kNumFramesToProcess); 93 test::PerformanceTimer timer(kNumFramesToProcess / kProcessingBatchSize);
84 94
85 webrtc::Config config; 95 webrtc::Config config;
86 AudioProcessing::Config apm_config; 96 AudioProcessing::Config apm_config;
87 if (include_default_apm_processing) { 97 if (include_default_apm_processing) {
88 config.Set<DelayAgnostic>(new DelayAgnostic(true)); 98 config.Set<DelayAgnostic>(new DelayAgnostic(true));
89 config.Set<ExtendedFilter>(new ExtendedFilter(true)); 99 config.Set<ExtendedFilter>(new ExtendedFilter(true));
90 } 100 }
91 apm_config.level_controller.enabled = include_default_apm_processing; 101 apm_config.level_controller.enabled = include_default_apm_processing;
92 apm_config.residual_echo_detector.enabled = true; 102 apm_config.residual_echo_detector.enabled = true;
93 103
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) { 176 TEST(EchoDetectorPerformanceTest, ProcessingViaApm) {
167 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false); 177 RunTogetherWithApm("SimpleEchoDetectorViaApm", false, false);
168 } 178 }
169 179
170 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) { 180 TEST(EchoDetectorPerformanceTest, InteractionWithDefaultApm) {
171 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true); 181 RunTogetherWithApm("EchoDetectorAndDefaultDesktopApm", false, true);
172 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true); 182 RunTogetherWithApm("EchoDetectorAndDefaultMobileApm", true, true);
173 } 183 }
174 184
175 } // namespace webrtc 185 } // 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