| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // This program benchmarks the theoretical throughput of the cast library. | 5 // This program benchmarks the theoretical throughput of the cast library. |
| 6 // It runs using a fake clock, simulated network and fake codecs. This allows | 6 // It runs using a fake clock, simulated network and fake codecs. This allows |
| 7 // tests to run much faster than real time. | 7 // tests to run much faster than real time. |
| 8 // To run the program, run: | 8 // To run the program, run: |
| 9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc | 9 // $ ./out/Release/cast_benchmarks | tee benchmarkoutput.asc |
| 10 // This may take a while, when it is done, you can view the data with | 10 // This may take a while, when it is done, you can view the data with |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "base/debug/profiler.h" | 35 #include "base/debug/profiler.h" |
| 36 #include "base/memory/weak_ptr.h" | 36 #include "base/memory/weak_ptr.h" |
| 37 #include "base/run_loop.h" | 37 #include "base/run_loop.h" |
| 38 #include "base/stl_util.h" | 38 #include "base/stl_util.h" |
| 39 #include "base/strings/string_number_conversions.h" | 39 #include "base/strings/string_number_conversions.h" |
| 40 #include "base/strings/stringprintf.h" | 40 #include "base/strings/stringprintf.h" |
| 41 #include "base/test/simple_test_tick_clock.h" | 41 #include "base/test/simple_test_tick_clock.h" |
| 42 #include "base/threading/thread.h" | 42 #include "base/threading/thread.h" |
| 43 #include "base/time/tick_clock.h" | 43 #include "base/time/tick_clock.h" |
| 44 #include "media/base/audio_bus.h" | 44 #include "media/base/audio_bus.h" |
| 45 #include "media/base/fake_single_thread_task_runner.h" |
| 45 #include "media/base/video_frame.h" | 46 #include "media/base/video_frame.h" |
| 46 #include "media/cast/cast_config.h" | 47 #include "media/cast/cast_config.h" |
| 47 #include "media/cast/cast_environment.h" | 48 #include "media/cast/cast_environment.h" |
| 48 #include "media/cast/cast_receiver.h" | 49 #include "media/cast/cast_receiver.h" |
| 49 #include "media/cast/cast_sender.h" | 50 #include "media/cast/cast_sender.h" |
| 50 #include "media/cast/logging/simple_event_subscriber.h" | 51 #include "media/cast/logging/simple_event_subscriber.h" |
| 51 #include "media/cast/net/cast_transport_config.h" | 52 #include "media/cast/net/cast_transport_config.h" |
| 52 #include "media/cast/net/cast_transport_defines.h" | 53 #include "media/cast/net/cast_transport_defines.h" |
| 53 #include "media/cast/net/cast_transport_sender.h" | 54 #include "media/cast/net/cast_transport_sender.h" |
| 54 #include "media/cast/net/cast_transport_sender_impl.h" | 55 #include "media/cast/net/cast_transport_sender_impl.h" |
| 55 #include "media/cast/test/fake_single_thread_task_runner.h" | |
| 56 #include "media/cast/test/loopback_transport.h" | 56 #include "media/cast/test/loopback_transport.h" |
| 57 #include "media/cast/test/skewed_single_thread_task_runner.h" | 57 #include "media/cast/test/skewed_single_thread_task_runner.h" |
| 58 #include "media/cast/test/skewed_tick_clock.h" | 58 #include "media/cast/test/skewed_tick_clock.h" |
| 59 #include "media/cast/test/utility/audio_utility.h" | 59 #include "media/cast/test/utility/audio_utility.h" |
| 60 #include "media/cast/test/utility/default_config.h" | 60 #include "media/cast/test/utility/default_config.h" |
| 61 #include "media/cast/test/utility/test_util.h" | 61 #include "media/cast/test/utility/test_util.h" |
| 62 #include "media/cast/test/utility/udp_proxy.h" | 62 #include "media/cast/test/utility/udp_proxy.h" |
| 63 #include "media/cast/test/utility/video_utility.h" | 63 #include "media/cast/test/utility/video_utility.h" |
| 64 #include "testing/gtest/include/gtest/gtest.h" | 64 #include "testing/gtest/include/gtest/gtest.h" |
| 65 | 65 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 double bitrate; | 203 double bitrate; |
| 204 double latency; | 204 double latency; |
| 205 double percent_packet_drop; | 205 double percent_packet_drop; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 class RunOneBenchmark { | 208 class RunOneBenchmark { |
| 209 public: | 209 public: |
| 210 RunOneBenchmark() | 210 RunOneBenchmark() |
| 211 : start_time_(), | 211 : start_time_(), |
| 212 task_runner_(new test::FakeSingleThreadTaskRunner(&testing_clock_)), | 212 task_runner_(new FakeSingleThreadTaskRunner(&testing_clock_)), |
| 213 testing_clock_sender_(new test::SkewedTickClock(&testing_clock_)), | 213 testing_clock_sender_(new test::SkewedTickClock(&testing_clock_)), |
| 214 task_runner_sender_( | 214 task_runner_sender_( |
| 215 new test::SkewedSingleThreadTaskRunner(task_runner_)), | 215 new test::SkewedSingleThreadTaskRunner(task_runner_)), |
| 216 testing_clock_receiver_(new test::SkewedTickClock(&testing_clock_)), | 216 testing_clock_receiver_(new test::SkewedTickClock(&testing_clock_)), |
| 217 task_runner_receiver_( | 217 task_runner_receiver_( |
| 218 new test::SkewedSingleThreadTaskRunner(task_runner_)), | 218 new test::SkewedSingleThreadTaskRunner(task_runner_)), |
| 219 cast_environment_sender_(new CastEnvironment( | 219 cast_environment_sender_(new CastEnvironment( |
| 220 scoped_ptr<base::TickClock>(testing_clock_sender_), | 220 scoped_ptr<base::TickClock>(testing_clock_sender_), |
| 221 task_runner_sender_, | 221 task_runner_sender_, |
| 222 task_runner_sender_, | 222 task_runner_sender_, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 private: | 411 private: |
| 412 FrameReceiverConfig audio_receiver_config_; | 412 FrameReceiverConfig audio_receiver_config_; |
| 413 FrameReceiverConfig video_receiver_config_; | 413 FrameReceiverConfig video_receiver_config_; |
| 414 AudioSenderConfig audio_sender_config_; | 414 AudioSenderConfig audio_sender_config_; |
| 415 VideoSenderConfig video_sender_config_; | 415 VideoSenderConfig video_sender_config_; |
| 416 | 416 |
| 417 base::TimeTicks start_time_; | 417 base::TimeTicks start_time_; |
| 418 | 418 |
| 419 // These run in "test time" | 419 // These run in "test time" |
| 420 base::SimpleTestTickClock testing_clock_; | 420 base::SimpleTestTickClock testing_clock_; |
| 421 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 421 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; |
| 422 | 422 |
| 423 // These run on the sender timeline. | 423 // These run on the sender timeline. |
| 424 test::SkewedTickClock* testing_clock_sender_; | 424 test::SkewedTickClock* testing_clock_sender_; |
| 425 scoped_refptr<test::SkewedSingleThreadTaskRunner> task_runner_sender_; | 425 scoped_refptr<test::SkewedSingleThreadTaskRunner> task_runner_sender_; |
| 426 | 426 |
| 427 // These run on the receiver timeline. | 427 // These run on the receiver timeline. |
| 428 test::SkewedTickClock* testing_clock_receiver_; | 428 test::SkewedTickClock* testing_clock_receiver_; |
| 429 scoped_refptr<test::SkewedSingleThreadTaskRunner> task_runner_receiver_; | 429 scoped_refptr<test::SkewedSingleThreadTaskRunner> task_runner_receiver_; |
| 430 | 430 |
| 431 scoped_refptr<CastEnvironment> cast_environment_sender_; | 431 scoped_refptr<CastEnvironment> cast_environment_sender_; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 media::cast::CastBenchmark benchmark; | 731 media::cast::CastBenchmark benchmark; |
| 732 if (getenv("PROFILE_FILE")) { | 732 if (getenv("PROFILE_FILE")) { |
| 733 std::string profile_file(getenv("PROFILE_FILE")); | 733 std::string profile_file(getenv("PROFILE_FILE")); |
| 734 base::debug::StartProfiling(profile_file); | 734 base::debug::StartProfiling(profile_file); |
| 735 benchmark.Run(); | 735 benchmark.Run(); |
| 736 base::debug::StopProfiling(); | 736 base::debug::StopProfiling(); |
| 737 } else { | 737 } else { |
| 738 benchmark.Run(); | 738 benchmark.Run(); |
| 739 } | 739 } |
| 740 } | 740 } |
| OLD | NEW |