diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index 7a3670f7a6..51d4a9163a 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc @@ -260,22 +260,12 @@ class TimedThreadApiProcessor { void print_processor_statistics(const std::string& processor_name) const { const std::string modifier = "_api_call_duration"; - // Lambda function for creating a test printout string. - auto create_mean_and_std_string = [](int64_t average, - int64_t standard_dev) { - std::string s = std::to_string(average); - s += ", "; - s += std::to_string(standard_dev); - return s; - }; - const std::string sample_rate_name = "_" + std::to_string(simulation_config_->sample_rate_hz) + "Hz"; webrtc::test::PrintResultMeanAndError( "apm_timing", sample_rate_name, processor_name, - create_mean_and_std_string(GetDurationAverage(), - GetDurationStandardDeviation()), + GetDurationAverage(), GetDurationStandardDeviation(), "us", false); if (kPrintAllDurations) { diff --git a/modules/audio_processing/level_controller/level_controller_complexity_unittest.cc b/modules/audio_processing/level_controller/level_controller_complexity_unittest.cc index 9aa10deb88..7d61cff21d 100644 --- a/modules/audio_processing/level_controller/level_controller_complexity_unittest.cc +++ b/modules/audio_processing/level_controller/level_controller_complexity_unittest.cc @@ -32,13 +32,6 @@ const size_t kNumFramesToProcessAtWarmup = 300; const size_t kToTalNumFrames = kNumFramesToProcess + kNumFramesToProcessAtWarmup; -std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer) { - std::string s = std::to_string(timer.GetDurationAverage()); - s += ", "; - s += std::to_string(timer.GetDurationStandardDeviation()); - return s; -} - void RunStandaloneSubmodule(int sample_rate_hz, size_t num_channels) { test::SimulatorBuffers buffers(sample_rate_hz, sample_rate_hz, sample_rate_hz, sample_rate_hz, num_channels, num_channels, @@ -63,8 +56,8 @@ void RunStandaloneSubmodule(int sample_rate_hz, size_t num_channels) { "level_controller_call_durations", "_" + std::to_string(sample_rate_hz) + "Hz_" + std::to_string(num_channels) + "_channels", - "StandaloneLevelControl", FormPerformanceMeasureString(timer), "us", - false); + "StandaloneLevelControl", timer.GetDurationAverage(), + timer.GetDurationStandardDeviation(), "us", false); } void RunTogetherWithApm(const std::string& test_description, @@ -164,8 +157,8 @@ void RunTogetherWithApm(const std::string& test_description, std::to_string(capture_input_sample_rate_hz) + "_" + std::to_string(capture_output_sample_rate_hz) + "Hz_" + std::to_string(num_channels) + "_channels" + "_render", - test_description, FormPerformanceMeasureString(render_timer), "us", - false); + test_description, render_timer.GetDurationAverage(), + render_timer.GetDurationStandardDeviation(), "us", false); webrtc::test::PrintResultMeanAndError( "level_controller_call_durations", "_" + std::to_string(render_input_sample_rate_hz) + "_" + @@ -173,8 +166,8 @@ void RunTogetherWithApm(const std::string& test_description, std::to_string(capture_input_sample_rate_hz) + "_" + std::to_string(capture_output_sample_rate_hz) + "Hz_" + std::to_string(num_channels) + "_channels" + "_capture", - test_description, FormPerformanceMeasureString(capture_timer), "us", - false); + test_description, capture_timer.GetDurationAverage(), + capture_timer.GetDurationStandardDeviation(), "us", false); webrtc::test::PrintResultMeanAndError( "level_controller_call_durations", "_" + std::to_string(render_input_sample_rate_hz) + "_" + @@ -182,7 +175,8 @@ void RunTogetherWithApm(const std::string& test_description, std::to_string(capture_input_sample_rate_hz) + "_" + std::to_string(capture_output_sample_rate_hz) + "Hz_" + std::to_string(num_channels) + "_channels" + "_total", - test_description, FormPerformanceMeasureString(total_timer), "us", false); + test_description, total_timer.GetDurationAverage(), + total_timer.GetDurationStandardDeviation(), "us", false); } } // namespace diff --git a/modules/audio_processing/residual_echo_detector_complexity_unittest.cc b/modules/audio_processing/residual_echo_detector_complexity_unittest.cc index 991b9ff47a..d829703e07 100644 --- a/modules/audio_processing/residual_echo_detector_complexity_unittest.cc +++ b/modules/audio_processing/residual_echo_detector_complexity_unittest.cc @@ -37,16 +37,6 @@ constexpr size_t kNumberOfWarmupMeasurementsStandalone = constexpr int kSampleRate = AudioProcessing::kSampleRate48kHz; constexpr int kNumberOfChannels = 1; -std::string FormPerformanceMeasureString(const test::PerformanceTimer& timer, - int number_of_warmup_samples) { - std::string s = - std::to_string(timer.GetDurationAverage(number_of_warmup_samples)); - s += ", "; - s += std::to_string( - timer.GetDurationStandardDeviation(number_of_warmup_samples)); - return s; -} - void RunStandaloneSubmodule() { test::SimulatorBuffers buffers( kSampleRate, kSampleRate, kSampleRate, kSampleRate, kNumberOfChannels, @@ -84,8 +74,8 @@ void RunStandaloneSubmodule() { EXPECT_EQ(0.0f, sum); webrtc::test::PrintResultMeanAndError( "echo_detector_call_durations", "", "StandaloneEchoDetector", - FormPerformanceMeasureString(timer, - kNumberOfWarmupMeasurementsStandalone), + timer.GetDurationAverage(kNumberOfWarmupMeasurementsStandalone), + timer.GetDurationStandardDeviation(kNumberOfWarmupMeasurementsStandalone), "us", false); } @@ -168,7 +158,8 @@ void RunTogetherWithApm(const std::string& test_description, webrtc::test::PrintResultMeanAndError( "echo_detector_call_durations", "_total", test_description, - FormPerformanceMeasureString(timer, kNumberOfWarmupMeasurements), "us", + timer.GetDurationAverage(kNumberOfWarmupMeasurements), + timer.GetDurationStandardDeviation(kNumberOfWarmupMeasurements), "us", false); } diff --git a/modules/remote_bitrate_estimator/test/bwe_test.cc b/modules/remote_bitrate_estimator/test/bwe_test.cc index f5fe38ee65..71088ff56e 100644 --- a/modules/remote_bitrate_estimator/test/bwe_test.cc +++ b/modules/remote_bitrate_estimator/test/bwe_test.cc @@ -225,15 +225,15 @@ void BweTest::PrintResults(double max_throughput_kbps, ss.str(""); ss << "Throughput flow " << kv.first; webrtc::test::PrintResultMeanAndError("BwePerformance", GetTestName(), - ss.str(), kv.second.AsString(), - "kbps", false); + ss.str(), kv.second.GetMean(), + kv.second.GetStdDev(), "kbps", false); } for (auto& kv : flow_delay_ms) { ss.str(""); ss << "Delay flow " << kv.first; webrtc::test::PrintResultMeanAndError("BwePerformance", GetTestName(), - ss.str(), kv.second.AsString(), "ms", - false); + ss.str(), kv.second.GetMean(), + kv.second.GetStdDev(), "ms", false); } double fairness_index = 1.0; if (!flow_throughput_kbps.empty()) { diff --git a/test/testsupport/perf_test.cc b/test/testsupport/perf_test.cc index e8608cdf77..bb4491af91 100644 --- a/test/testsupport/perf_test.cc +++ b/test/testsupport/perf_test.cc @@ -75,11 +75,14 @@ void PrintResult(const std::string& measurement, void PrintResultMeanAndError(const std::string& measurement, const std::string& modifier, const std::string& trace, - const std::string& mean_and_error, + const double mean, + const double error, const std::string& units, bool important) { - PrintResultsImpl(measurement, modifier, trace, mean_and_error, - "{", "}", units, important); + std::ostringstream value_stream; + value_stream << '{' << mean << ',' << error << '}'; + PrintResultsImpl(measurement, modifier, trace, value_stream.str(), "", "", + units, important); } void PrintResultList(const std::string& measurement, diff --git a/test/testsupport/perf_test.h b/test/testsupport/perf_test.h index 95bbf65dc1..02dd1f3713 100644 --- a/test/testsupport/perf_test.h +++ b/test/testsupport/perf_test.h @@ -47,7 +47,8 @@ void PrintResult(const std::string& measurement, void PrintResultMeanAndError(const std::string& measurement, const std::string& modifier, const std::string& trace, - const std::string& mean_and_error, + const double mean, + const double error, const std::string& units, bool important);