OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """Utility script to run the benchmarks during the profiling step of a PGO | 5 """Utility script to run the benchmarks during the profiling step of a PGO |
6 build. | 6 build. |
7 """ | 7 """ |
8 | 8 |
9 import json | 9 import json |
10 import optparse | 10 import optparse |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 'dromaeo.jslibtraversejquery', | 45 'dromaeo.jslibtraversejquery', |
46 'dromaeo.jslibtraverseprototype', | 46 'dromaeo.jslibtraverseprototype', |
47 'media.tough_video_cases', | 47 'media.tough_video_cases', |
48 'octane', | 48 'octane', |
49 'smoothness.top_25_smooth', | 49 'smoothness.top_25_smooth', |
50 'storage.indexeddb_endure_tracing', | 50 'storage.indexeddb_endure_tracing', |
51 'sunspider', | 51 'sunspider', |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 def FindPgosweep(target_cpu): | |
56 """Find the directory containing pgosweep.exe. | |
57 | |
58 Note: |target_cpu| should be x86 or x64. | |
59 """ | |
60 if target_cpu not in ('x86', 'x64'): | |
61 raise Exception('target_cpu should be x86 or x64.') | |
62 win_toolchain_json_file = os.path.join(_CHROME_BUILD_DIR, | |
63 'win_toolchain.json') | |
64 if not os.path.exists(win_toolchain_json_file): | |
65 raise Exception('The toolchain JSON file (%s) is missing.' % | |
66 win_toolchain_json_file) | |
67 with open(win_toolchain_json_file) as temp_f: | |
68 toolchain_data = json.load(temp_f) | |
69 if not os.path.isdir(toolchain_data['path']): | |
70 raise Exception('The toolchain JSON file\'s "path" entry (%s) does not ' | |
71 'refer to a path.' % win_toolchain_json_file) | |
72 | |
73 pgo_sweep_dir = os.path.join(toolchain_data['path'], 'VC', 'bin') | |
74 if target_cpu == 'x64': | |
75 pgo_sweep_dir = os.path.join(pgo_sweep_dir, 'amd64') | |
76 | |
77 if not os.path.exists(os.path.join(pgo_sweep_dir, 'pgosweep.exe')): | |
78 raise Exception('pgosweep.exe is missing from %s.' % pgo_sweep_dir) | |
79 | |
80 return pgo_sweep_dir | |
81 | |
82 | |
83 def RunBenchmarks(options): | 55 def RunBenchmarks(options): |
84 """Run the benchmarks.""" | 56 """Run the benchmarks.""" |
85 # Starts by finding the directory containing pgosweep.exe | |
86 pgo_sweep_dir = FindPgosweep(options.target_cpu) | |
87 | |
88 # Find the run_benchmark script. | 57 # Find the run_benchmark script. |
89 chrome_run_benchmark_script = os.path.join(_CHROME_SRC_DIR, 'tools', | 58 chrome_run_benchmark_script = os.path.join(_CHROME_SRC_DIR, 'tools', |
90 'perf', 'run_benchmark') | 59 'perf', 'run_benchmark') |
91 if not os.path.exists(chrome_run_benchmark_script): | 60 if not os.path.exists(chrome_run_benchmark_script): |
92 raise Exception('Unable to find the run_benchmark script ' | 61 raise Exception('Unable to find the run_benchmark script ' |
93 '(%s doesn\'t exist) ' % chrome_run_benchmark_script) | 62 '(%s doesn\'t exist) ' % chrome_run_benchmark_script) |
94 | 63 |
95 # Augment the PATH to make sure that the benchmarking script can find | 64 # Augment the PATH to make sure that the benchmarking script can find |
96 # pgosweep.exe and its runtime libraries. | 65 # pgosweep.exe and its runtime libraries. |
97 env = os.environ.copy() | 66 env = os.environ.copy() |
98 env['PATH'] = str(os.pathsep.join([pgo_sweep_dir, options.build_dir, | 67 env['PATH'] = str(os.pathsep.join([options.build_dir, os.environ['PATH']])) |
99 os.environ['PATH']])) | |
100 env['PogoSafeMode'] = '1' | 68 env['PogoSafeMode'] = '1' |
101 # Apply a scaling factor of 0.5 to the PGO profiling buffers for the 32-bit | 69 # Apply a scaling factor of 0.5 to the PGO profiling buffers for the 32-bit |
102 # builds, without this the buffers will be too large and the process will | 70 # builds, without this the buffers will be too large and the process will |
103 # fail to start. See crbug.com/632864#c22. | 71 # fail to start. See crbug.com/632864#c22. |
104 if options.target_cpu == 'x86': | 72 if options.target_cpu == 'x86': |
105 env['VCPROFILE_ALLOC_SCALE'] = '0.5' | 73 env['VCPROFILE_ALLOC_SCALE'] = '0.5' |
106 | 74 |
107 # Run all the benchmarks. | 75 # Run all the benchmarks. |
108 # TODO(sebmarchand): Make this run in parallel. | 76 # TODO(sebmarchand): Make this run in parallel. |
109 for benchmark in _BENCHMARKS_TO_RUN: | 77 for benchmark in _BENCHMARKS_TO_RUN: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 if not options.build_dir: | 114 if not options.build_dir: |
147 parser.error('--build-dir is required') | 115 parser.error('--build-dir is required') |
148 if not options.browser_type: | 116 if not options.browser_type: |
149 options.browser_type = 'exact' | 117 options.browser_type = 'exact' |
150 | 118 |
151 return RunBenchmarks(options) | 119 return RunBenchmarks(options) |
152 | 120 |
153 | 121 |
154 if __name__ == '__main__': | 122 if __name__ == '__main__': |
155 sys.exit(main()) | 123 sys.exit(main()) |
OLD | NEW |