| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 def _ComputeChromeCategories(options): | 25 def _ComputeChromeCategories(options): |
| 26 categories = [] | 26 categories = [] |
| 27 if options.trace_frame_viewer: | 27 if options.trace_frame_viewer: |
| 28 categories.append('disabled-by-default-cc.debug') | 28 categories.append('disabled-by-default-cc.debug') |
| 29 if options.trace_ubercompositor: | 29 if options.trace_ubercompositor: |
| 30 categories.append('disabled-by-default-cc.debug*') | 30 categories.append('disabled-by-default-cc.debug*') |
| 31 if options.trace_gpu: | 31 if options.trace_gpu: |
| 32 categories.append('disabled-by-default-gpu.debug*') | 32 categories.append('disabled-by-default-gpu.debug*') |
| 33 if options.trace_flow: | 33 if options.trace_flow: |
| 34 categories.append('disabled-by-default-toplevel.flow') | 34 categories.append('disabled-by-default-toplevel.flow') |
| 35 if options.trace_memory: |
| 36 categories.append('disabled-by-default-memory') |
| 35 if options.chrome_categories: | 37 if options.chrome_categories: |
| 36 categories += options.chrome_categories.split(',') | 38 categories += options.chrome_categories.split(',') |
| 37 return categories | 39 return categories |
| 38 | 40 |
| 39 | 41 |
| 40 def _ComputeSystraceCategories(options): | 42 def _ComputeSystraceCategories(options): |
| 41 if not options.systrace_categories: | 43 if not options.systrace_categories: |
| 42 return [] | 44 return [] |
| 43 return options.systrace_categories.split(',') | 45 return options.systrace_categories.split(',') |
| 44 | 46 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 chrome_opts.add_option('--trace-frame-viewer', | 82 chrome_opts.add_option('--trace-frame-viewer', |
| 81 help='Enable enough trace categories for ' | 83 help='Enable enough trace categories for ' |
| 82 'compositor frame viewing.', action='store_true') | 84 'compositor frame viewing.', action='store_true') |
| 83 chrome_opts.add_option('--trace-ubercompositor', | 85 chrome_opts.add_option('--trace-ubercompositor', |
| 84 help='Enable enough trace categories for ' | 86 help='Enable enough trace categories for ' |
| 85 'ubercompositor frame data.', action='store_true') | 87 'ubercompositor frame data.', action='store_true') |
| 86 chrome_opts.add_option('--trace-gpu', help='Enable extra trace categories ' | 88 chrome_opts.add_option('--trace-gpu', help='Enable extra trace categories ' |
| 87 'for GPU data.', action='store_true') | 89 'for GPU data.', action='store_true') |
| 88 chrome_opts.add_option('--trace-flow', help='Enable extra trace categories ' | 90 chrome_opts.add_option('--trace-flow', help='Enable extra trace categories ' |
| 89 'for IPC message flows.', action='store_true') | 91 'for IPC message flows.', action='store_true') |
| 92 chrome_opts.add_option('--trace-memory', help='Enable extra trace categories ' |
| 93 'for memory profile. (tcmalloc required)', |
| 94 action='store_true') |
| 90 parser.add_option_group(chrome_opts) | 95 parser.add_option_group(chrome_opts) |
| 91 | 96 |
| 92 systrace_opts = optparse.OptionGroup(parser, 'Systrace tracing options') | 97 systrace_opts = optparse.OptionGroup(parser, 'Systrace tracing options') |
| 93 systrace_opts.add_option('-s', '--systrace', help='Capture a systrace with ' | 98 systrace_opts.add_option('-s', '--systrace', help='Capture a systrace with ' |
| 94 'the chosen comma-delimited systrace categories. You ' | 99 'the chosen comma-delimited systrace categories. You ' |
| 95 'can also capture a combined Chrome + systrace by ' | 100 'can also capture a combined Chrome + systrace by ' |
| 96 'enable both types of categories. Use "list" to see ' | 101 'enable both types of categories. Use "list" to see ' |
| 97 'the available categories. Systrace is disabled by ' | 102 'the available categories. Systrace is disabled by ' |
| 98 'default.', metavar='SYS_CATEGORIES', | 103 'default.', metavar='SYS_CATEGORIES', |
| 99 dest='systrace_categories', default='') | 104 dest='systrace_categories', default='') |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if chrome_categories and 'webview' in systrace_categories: | 179 if chrome_categories and 'webview' in systrace_categories: |
| 175 logging.warning('Using the "webview" category in systrace together with ' | 180 logging.warning('Using the "webview" category in systrace together with ' |
| 176 'Chrome tracing results in duplicate trace events.') | 181 'Chrome tracing results in duplicate trace events.') |
| 177 | 182 |
| 178 enabled_controllers = [] | 183 enabled_controllers = [] |
| 179 if chrome_categories: | 184 if chrome_categories: |
| 180 enabled_controllers.append( | 185 enabled_controllers.append( |
| 181 chrome_controller.ChromeTracingController(device, | 186 chrome_controller.ChromeTracingController(device, |
| 182 package_info, | 187 package_info, |
| 183 chrome_categories, | 188 chrome_categories, |
| 184 options.ring_buffer)) | 189 options.ring_buffer, |
| 190 options.trace_memory)) |
| 185 if systrace_categories: | 191 if systrace_categories: |
| 186 enabled_controllers.append( | 192 enabled_controllers.append( |
| 187 systrace_controller.SystraceController(device, | 193 systrace_controller.SystraceController(device, |
| 188 systrace_categories, | 194 systrace_categories, |
| 189 options.ring_buffer)) | 195 options.ring_buffer)) |
| 190 | 196 |
| 191 if not enabled_controllers: | 197 if not enabled_controllers: |
| 192 ui.PrintMessage('No trace categories enabled.') | 198 ui.PrintMessage('No trace categories enabled.') |
| 193 return 1 | 199 return 1 |
| 194 | 200 |
| 195 if options.output: | 201 if options.output: |
| 196 options.output = os.path.expanduser(options.output) | 202 options.output = os.path.expanduser(options.output) |
| 197 result = profiler.CaptureProfile( | 203 result = profiler.CaptureProfile( |
| 198 enabled_controllers, | 204 enabled_controllers, |
| 199 options.time if not options.continuous else 0, | 205 options.time if not options.continuous else 0, |
| 200 output=options.output, | 206 output=options.output, |
| 201 compress=options.compress, | 207 compress=options.compress, |
| 202 write_json=options.json) | 208 write_json=options.json) |
| 203 if options.view: | 209 if options.view: |
| 204 if sys.platform == 'darwin': | 210 if sys.platform == 'darwin': |
| 205 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 211 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
| 206 else: | 212 else: |
| 207 webbrowser.open(result) | 213 webbrowser.open(result) |
| 208 | 214 |
| 209 | 215 |
| 210 if __name__ == '__main__': | 216 if __name__ == '__main__': |
| 211 sys.exit(main()) | 217 sys.exit(main()) |
| OLD | NEW |