1 /* 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "api/test/metrics/global_metrics_logger_and_exporter.h" 12 #include "api/test/metrics/metric.h" 13 #include "modules/audio_coding/neteq/tools/neteq_performance_test.h" 14 #include "system_wrappers/include/field_trial.h" 15 #include "test/gtest.h" 16 17 namespace webrtc { 18 namespace { 19 20 using ::webrtc::test::GetGlobalMetricsLogger; 21 using ::webrtc::test::ImprovementDirection; 22 using ::webrtc::test::Unit; 23 24 // Runs a test with 10% packet losses and 10% clock drift, to exercise 25 // both loss concealment and time-stretching code. 26 TEST(NetEqPerformanceTest, 10_Pl_10_Drift) { 27 const int kSimulationTimeMs = 10000000; 28 const int kQuickSimulationTimeMs = 100000; 29 const int kLossPeriod = 10; // Drop every 10th packet. 30 const double kDriftFactor = 0.1; 31 int64_t runtime = test::NetEqPerformanceTest::Run( 32 field_trial::IsEnabled("WebRTC-QuickPerfTest") ? kQuickSimulationTimeMs 33 : kSimulationTimeMs, 34 kLossPeriod, kDriftFactor); 35 ASSERT_GT(runtime, 0); 36 GetGlobalMetricsLogger()->LogSingleValueMetric( 37 "neteq_performance", "10_pl_10_drift", runtime, Unit::kMilliseconds, 38 ImprovementDirection::kNeitherIsBetter); 39 } 40 41 // Runs a test with neither packet losses nor clock drift, to put 42 // emphasis on the "good-weather" code path, which is presumably much 43 // more lightweight. 44 TEST(NetEqPerformanceTest, 0_Pl_0_Drift) { 45 const int kSimulationTimeMs = 10000000; 46 const int kQuickSimulationTimeMs = 100000; 47 const int kLossPeriod = 0; // No losses. 48 const double kDriftFactor = 0.0; // No clock drift. 49 int64_t runtime = test::NetEqPerformanceTest::Run( 50 field_trial::IsEnabled("WebRTC-QuickPerfTest") ? kQuickSimulationTimeMs 51 : kSimulationTimeMs, 52 kLossPeriod, kDriftFactor); 53 ASSERT_GT(runtime, 0); 54 GetGlobalMetricsLogger()->LogSingleValueMetric( 55 "neteq_performance", "0_pl_0_drift", runtime, Unit::kMilliseconds, 56 ImprovementDirection::kNeitherIsBetter); 57 } 58 59 } // namespace 60 } // namespace webrtc 61