OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 gzip | 7 import gzip |
8 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 16 matching lines...) Expand all Loading... | |
27 } | 27 } |
28 supported_browsers.update(constants.PACKAGE_INFO) | 28 supported_browsers.update(constants.PACKAGE_INFO) |
29 unsupported_browsers = ['content_browsertests', 'gtest', 'legacy_browser'] | 29 unsupported_browsers = ['content_browsertests', 'gtest', 'legacy_browser'] |
30 for browser in unsupported_browsers: | 30 for browser in unsupported_browsers: |
31 del supported_browsers[browser] | 31 del supported_browsers[browser] |
32 return supported_browsers | 32 return supported_browsers |
33 | 33 |
34 | 34 |
35 def _StartTracing(adb, package_info, categories, continuous): | 35 def _StartTracing(adb, package_info, categories, continuous): |
36 adb.BroadcastIntent(package_info.package, 'GPU_PROFILER_START', | 36 adb.BroadcastIntent(package_info.package, 'GPU_PROFILER_START', |
37 '-e categories "%s"' % categories, | 37 '-e categories "%s"' % categories if categories else '', |
38 '-e continuous' if continuous else '') | 38 '-e continuous' if continuous else '') |
39 | 39 |
40 | 40 |
41 def _StopTracing(adb, package_info): | 41 def _StopTracing(adb, package_info): |
42 adb.BroadcastIntent(package_info.package, 'GPU_PROFILER_STOP') | 42 adb.BroadcastIntent(package_info.package, 'GPU_PROFILER_STOP') |
43 | 43 |
44 | 44 |
45 def _GetLatestTraceFileName(adb, check_for_multiple_traces=True): | 45 def _GetLatestTraceFileName(adb, check_for_multiple_traces=True): |
46 # Chrome logs two different messages related to tracing: | 46 # Chrome logs two different messages related to tracing: |
47 # | 47 # |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 _StopTracing(adb, package_info) | 124 _StopTracing(adb, package_info) |
125 _PrintMessage('done') | 125 _PrintMessage('done') |
126 | 126 |
127 # Wait a bit for the browser to finish writing the trace file. | 127 # Wait a bit for the browser to finish writing the trace file. |
128 time.sleep(interval / 4 + 1) | 128 time.sleep(interval / 4 + 1) |
129 | 129 |
130 _DownloadLatestTrace(adb, compress, check_for_multiple_traces=False) | 130 _DownloadLatestTrace(adb, compress, check_for_multiple_traces=False) |
131 | 131 |
132 | 132 |
133 def _ComputeCategories(options): | 133 def _ComputeCategories(options): |
134 categories = [options.categories] | 134 categories = [options.categories] if options.categories else [] |
135 if options.trace_cc: | 135 if options.trace_cc: |
136 categories.append('disabled-by-default-cc.debug*') | 136 categories.append('disabled-by-default-cc.debug*') |
137 if options.trace_gpu: | 137 if options.trace_gpu: |
138 categories.append('disabled-by-default-gpu.debug*') | 138 categories.append('disabled-by-default-gpu.debug*') |
139 return ",".join(categories) | 139 return ",".join(categories) |
140 | 140 |
141 | 141 |
142 def main(): | 142 def main(): |
143 parser = optparse.OptionParser(description='Record about://tracing profiles ' | 143 parser = optparse.OptionParser(description='Record about://tracing profiles ' |
144 'from Android browsers. See http://dev.' | 144 'from Android browsers. See http://dev.' |
(...skipping 11 matching lines...) Expand all Loading... | |
156 | 156 |
157 auto_options = optparse.OptionGroup(parser, 'Automated tracing') | 157 auto_options = optparse.OptionGroup(parser, 'Automated tracing') |
158 auto_options.add_option('-t', '--time', help='Profile for N seconds and ' | 158 auto_options.add_option('-t', '--time', help='Profile for N seconds and ' |
159 'download the resulting trace.', metavar='N', | 159 'download the resulting trace.', metavar='N', |
160 type='float') | 160 type='float') |
161 parser.add_option_group(auto_options) | 161 parser.add_option_group(auto_options) |
162 | 162 |
163 categories = optparse.OptionGroup(parser, 'Trace categories') | 163 categories = optparse.OptionGroup(parser, 'Trace categories') |
164 categories.add_option('-c', '--categories', help='Select categories to trace ' | 164 categories.add_option('-c', '--categories', help='Select categories to trace ' |
165 'with comma-delimited wildcards, e.g., ' | 165 'with comma-delimited wildcards, e.g., ' |
166 '"*", "cat1*,-cat1a". Default is "*".', default='*') | 166 '"*", "cat1*,-cat1a".') |
Sami
2013/10/14 11:22:19
Having an emptry string imply default categories i
Xianzhu
2013/10/14 16:44:40
Do you mean '--categories ""' to opt-out chromium
| |
167 categories.add_option('--trace-cc', help='Enable extra trace categories for ' | 167 categories.add_option('--trace-cc', help='Enable extra trace categories for ' |
168 'compositor frame viewer data.', action='store_true') | 168 'compositor frame viewer data.', action='store_true') |
169 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' | 169 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' |
170 'GPU data.', action='store_true') | 170 'GPU data.', action='store_true') |
171 parser.add_option_group(categories) | 171 parser.add_option_group(categories) |
172 | 172 |
173 parser.add_option('-o', '--output', help='Save profile output to file. ' | 173 parser.add_option('-o', '--output', help='Save profile output to file. ' |
174 'Default is "/sdcard/Download/chrome-profile-results-*".') | 174 'Default is "/sdcard/Download/chrome-profile-results-*".') |
175 parser.add_option('--continuous', help='Using the trace buffer as a ring ' | 175 parser.add_option('--continuous', help='Using the trace buffer as a ring ' |
176 'buffer, continuously profile until stopped.', | 176 'buffer, continuously profile until stopped.', |
(...skipping 26 matching lines...) Expand all Loading... | |
203 _StopTracing(adb, package_info) | 203 _StopTracing(adb, package_info) |
204 elif options.download: | 204 elif options.download: |
205 _DownloadLatestTrace(adb, options.compress) | 205 _DownloadLatestTrace(adb, options.compress) |
206 elif options.time: | 206 elif options.time: |
207 _CaptureAndDownloadTimedTrace(adb, package_info, categories, options.time, | 207 _CaptureAndDownloadTimedTrace(adb, package_info, categories, options.time, |
208 options.continuous, options.compress) | 208 options.continuous, options.compress) |
209 | 209 |
210 | 210 |
211 if __name__ == '__main__': | 211 if __name__ == '__main__': |
212 sys.exit(main()) | 212 sys.exit(main()) |
OLD | NEW |