| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 void Run() { | 691 void Run() { |
| 692 // Spanning search. | 692 // Spanning search. |
| 693 | 693 |
| 694 std::vector<linked_ptr<base::Thread> > threads; | 694 std::vector<linked_ptr<base::Thread> > threads; |
| 695 for (int i = 0; i < 16; i++) { | 695 for (int i = 0; i < 16; i++) { |
| 696 threads.push_back(make_linked_ptr(new base::Thread( | 696 threads.push_back(make_linked_ptr(new base::Thread( |
| 697 base::StringPrintf("cast_bench_thread_%d", i)))); | 697 base::StringPrintf("cast_bench_thread_%d", i)))); |
| 698 threads[i]->Start(); | 698 threads[i]->Start(); |
| 699 } | 699 } |
| 700 | 700 |
| 701 if (CommandLine::ForCurrentProcess()->HasSwitch("single-run")) { | 701 if (base::CommandLine::ForCurrentProcess()->HasSwitch("single-run")) { |
| 702 SearchVector a; | 702 SearchVector a; |
| 703 a.bitrate.base = 100.0; | 703 a.bitrate.base = 100.0; |
| 704 a.bitrate.grade = 1.0; | 704 a.bitrate.grade = 1.0; |
| 705 a.latency.grade = 1.0; | 705 a.latency.grade = 1.0; |
| 706 a.packet_drop.grade = 1.0; | 706 a.packet_drop.grade = 1.0; |
| 707 threads[0]->message_loop()->PostTask( | 707 threads[0]->message_loop()->PostTask( |
| 708 FROM_HERE, | 708 FROM_HERE, |
| 709 base::Bind(base::IgnoreResult(&CastBenchmark::RunOnePoint), | 709 base::Bind(base::IgnoreResult(&CastBenchmark::RunOnePoint), |
| 710 base::Unretained(this), | 710 base::Unretained(this), |
| 711 a, | 711 a, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 736 private: | 736 private: |
| 737 BenchmarkCache<MeasuringPoint> cache_; | 737 BenchmarkCache<MeasuringPoint> cache_; |
| 738 base::Lock lock_; | 738 base::Lock lock_; |
| 739 }; | 739 }; |
| 740 | 740 |
| 741 } // namespace cast | 741 } // namespace cast |
| 742 } // namespace media | 742 } // namespace media |
| 743 | 743 |
| 744 int main(int argc, char** argv) { | 744 int main(int argc, char** argv) { |
| 745 base::AtExitManager at_exit; | 745 base::AtExitManager at_exit; |
| 746 CommandLine::Init(argc, argv); | 746 base::CommandLine::Init(argc, argv); |
| 747 media::cast::CastBenchmark benchmark; | 747 media::cast::CastBenchmark benchmark; |
| 748 if (getenv("PROFILE_FILE")) { | 748 if (getenv("PROFILE_FILE")) { |
| 749 std::string profile_file(getenv("PROFILE_FILE")); | 749 std::string profile_file(getenv("PROFILE_FILE")); |
| 750 base::debug::StartProfiling(profile_file); | 750 base::debug::StartProfiling(profile_file); |
| 751 benchmark.Run(); | 751 benchmark.Run(); |
| 752 base::debug::StopProfiling(); | 752 base::debug::StopProfiling(); |
| 753 } else { | 753 } else { |
| 754 benchmark.Run(); | 754 benchmark.Run(); |
| 755 } | 755 } |
| 756 } | 756 } |
| OLD | NEW |