OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import logging | 7 import logging |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 import webbrowser | 11 import webbrowser |
12 | 12 |
13 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, | 13 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, |
14 'build', 'android')) | 14 'build', 'android')) |
15 | 15 |
16 from profile_chrome import chrome_startup_controller | 16 from profile_chrome import chrome_startup_controller |
17 from profile_chrome import controllers | 17 from profile_chrome import controllers |
18 from profile_chrome import flags | 18 from profile_chrome import flags |
19 from profile_chrome import profiler | 19 from profile_chrome import profiler |
20 from profile_chrome import systrace_controller | 20 from profile_chrome import systrace_controller |
21 from profile_chrome import ui | 21 from profile_chrome import ui |
22 from pylib import android_commands | |
23 from pylib.device import device_utils | 22 from pylib.device import device_utils |
24 | 23 |
25 | 24 |
26 def _CreateOptionParser(): | 25 def _CreateOptionParser(): |
27 parser = optparse.OptionParser(description='Record about://tracing profiles ' | 26 parser = optparse.OptionParser(description='Record about://tracing profiles ' |
28 'from Android browsers startup, combined with ' | 27 'from Android browsers startup, combined with ' |
29 'Android systrace. See http://dev.chromium.org' | 28 'Android systrace. See http://dev.chromium.org' |
30 '/developers/how-tos/trace-event-profiling-' | 29 '/developers/how-tos/trace-event-profiling-' |
31 'tool for detailed instructions for ' | 30 'tool for detailed instructions for ' |
32 'profiling.') | 31 'profiling.') |
(...skipping 18 matching lines...) Expand all Loading... |
51 return parser | 50 return parser |
52 | 51 |
53 | 52 |
54 def main(): | 53 def main(): |
55 parser = _CreateOptionParser() | 54 parser = _CreateOptionParser() |
56 options, _ = parser.parse_args() | 55 options, _ = parser.parse_args() |
57 | 56 |
58 if options.verbose: | 57 if options.verbose: |
59 logging.getLogger().setLevel(logging.DEBUG) | 58 logging.getLogger().setLevel(logging.DEBUG) |
60 | 59 |
61 devices = android_commands.GetAttachedDevices() | 60 devices = device_utils.DeviceUtils.HealthyDevices() |
62 if len(devices) != 1: | 61 if len(devices) != 1: |
63 logging.error('Exactly 1 device must be attached.') | 62 logging.error('Exactly 1 device must be attached.') |
64 return 1 | 63 return 1 |
65 device = device_utils.DeviceUtils(devices[0]) | 64 device = devices[0] |
66 package_info = profiler.GetSupportedBrowsers()[options.browser] | 65 package_info = profiler.GetSupportedBrowsers()[options.browser] |
67 | 66 |
68 if options.systrace_categories in ['list', 'help']: | 67 if options.systrace_categories in ['list', 'help']: |
69 ui.PrintMessage('\n'.join( | 68 ui.PrintMessage('\n'.join( |
70 systrace_controller.SystraceController.GetCategories(device))) | 69 systrace_controller.SystraceController.GetCategories(device))) |
71 return 0 | 70 return 0 |
72 systrace_categories = (options.systrace_categories.split(',') | 71 systrace_categories = (options.systrace_categories.split(',') |
73 if options.systrace_categories else []) | 72 if options.systrace_categories else []) |
74 enabled_controllers = [] | 73 enabled_controllers = [] |
75 # Enable the systrace and chrome controller. The systrace controller should go | 74 # Enable the systrace and chrome controller. The systrace controller should go |
(...skipping 12 matching lines...) Expand all Loading... |
88 write_json=options.json) | 87 write_json=options.json) |
89 if options.view: | 88 if options.view: |
90 if sys.platform == 'darwin': | 89 if sys.platform == 'darwin': |
91 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 90 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
92 else: | 91 else: |
93 webbrowser.open(result) | 92 webbrowser.open(result) |
94 | 93 |
95 | 94 |
96 if __name__ == '__main__': | 95 if __name__ == '__main__': |
97 sys.exit(main()) | 96 sys.exit(main()) |
OLD | NEW |