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 |
11 // meshlab by running: | 11 // meshlab by running: |
12 // $ meshlab benchmarkoutput.asc | 12 // $ meshlab benchmarkoutput.asc |
13 // After starting meshlab, turn on Render->Show Axis. The red axis will | 13 // After starting meshlab, turn on Render->Show Axis. The red axis will |
14 // represent bandwidth (in megabits) the blue axis will be packet drop | 14 // represent bandwidth (in megabits) the blue axis will be packet drop |
15 // (in percent) and the green axis will be latency (in milliseconds). | 15 // (in percent) and the green axis will be latency (in milliseconds). |
16 // | 16 // |
17 // This program can also be used for profiling. On linux it has | 17 // This program can also be used for profiling. On linux it has |
18 // built-in support for this. Simply set the environment variable | 18 // built-in support for this. Simply set the environment variable |
19 // PROFILE_FILE before running it, like so: | 19 // PROFILE_FILE before running it, like so: |
20 // $ export PROFILE_FILE=cast_benchmark.profile | 20 // $ export PROFILE_FILE=cast_benchmark.profile |
21 // Then after running the program, you can view the profile with: | 21 // Then after running the program, you can view the profile with: |
22 // $ pprof ./out/Release/cast_benchmarks $PROFILE_FILE --gv | 22 // $ pprof ./out/Release/cast_benchmarks $PROFILE_FILE --gv |
23 | 23 |
24 #include <math.h> | 24 #include <math.h> |
| 25 #include <stddef.h> |
25 #include <stdint.h> | 26 #include <stdint.h> |
26 | 27 |
27 #include <map> | 28 #include <map> |
28 #include <vector> | 29 #include <vector> |
29 | 30 |
30 #include "base/at_exit.h" | 31 #include "base/at_exit.h" |
31 #include "base/bind.h" | 32 #include "base/bind.h" |
32 #include "base/bind_helpers.h" | 33 #include "base/bind_helpers.h" |
33 #include "base/command_line.h" | 34 #include "base/command_line.h" |
34 #include "base/debug/profiler.h" | 35 #include "base/debug/profiler.h" |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 media::cast::CastBenchmark benchmark; | 720 media::cast::CastBenchmark benchmark; |
720 if (getenv("PROFILE_FILE")) { | 721 if (getenv("PROFILE_FILE")) { |
721 std::string profile_file(getenv("PROFILE_FILE")); | 722 std::string profile_file(getenv("PROFILE_FILE")); |
722 base::debug::StartProfiling(profile_file); | 723 base::debug::StartProfiling(profile_file); |
723 benchmark.Run(); | 724 benchmark.Run(); |
724 base::debug::StopProfiling(); | 725 base::debug::StopProfiling(); |
725 } else { | 726 } else { |
726 benchmark.Run(); | 727 benchmark.Run(); |
727 } | 728 } |
728 } | 729 } |
OLD | NEW |