def testTracing(self): categories = ['gfx', 'input', 'view'] ring_buffer = False controller = systrace_controller.SystraceController( self.device, categories, ring_buffer) interval = 1 try: controller.StartTracing(interval) finally: controller.StopTracing() result = controller.PullTrace() try: with open(result) as f: self.assertTrue('CPU#' in f.read()) finally: os.remove(result)
def main(): parser = _CreateOptionParser() options, _ = parser.parse_args() if options.verbose: logging.getLogger().setLevel(logging.DEBUG) devices = device_utils.DeviceUtils.HealthyDevices() if len(devices) != 1: logging.error('Exactly 1 device must be attached.') return 1 device = devices[0] package_info = profiler.GetSupportedBrowsers()[options.browser] if options.systrace_categories in ['list', 'help']: ui.PrintMessage('\n'.join( systrace_controller.SystraceController.GetCategories(device))) return 0 systrace_categories = (options.systrace_categories.split(',') if options.systrace_categories else []) enabled_controllers = [] # Enable the systrace and chrome controller. The systrace controller should go # first because otherwise the resulting traces miss early systrace data. if systrace_categories: enabled_controllers.append( systrace_controller.SystraceController(device, systrace_categories, False)) enabled_controllers.append( chrome_startup_controller.ChromeStartupTracingController( device, package_info, options.cold, options.url)) if options.output: options.output = os.path.expanduser(options.output) result = profiler.CaptureProfile(enabled_controllers, options.time, output=options.output, compress=options.compress, write_json=options.json) if options.view: if sys.platform == 'darwin': os.system('/usr/bin/open %s' % os.path.abspath(result)) else: webbrowser.open(result)
def main(): parser = _CreateOptionParser() options, _args = parser.parse_args() if options.trace_cc: parser.parse_error("""--trace-cc is deprecated. For basic jank busting uses, use --trace-frame-viewer For detailed study of ubercompositor, pass --trace-ubercompositor. When in doubt, just try out --trace-frame-viewer. """) if options.verbose: logging.getLogger().setLevel(logging.DEBUG) devices = device_utils.DeviceUtils.HealthyDevices() device = None if options.device: device = next((d for d in devices if d == options.device), None) elif len(devices) == 1: device = devices[0] if not device: parser.error('Use -d/--device to select a device:\n' + '\n'.join(devices)) package_info = profiler.GetSupportedBrowsers()[options.browser] if options.chrome_categories in ['list', 'help']: ui.PrintMessage('Collecting record categories list...', eol='') record_categories = [] disabled_by_default_categories = [] record_categories, disabled_by_default_categories = \ chrome_controller.ChromeTracingController.GetCategories( device, package_info) ui.PrintMessage('done') ui.PrintMessage('Record Categories:') ui.PrintMessage('\n'.join('\t%s' % item \ for item in sorted(record_categories))) ui.PrintMessage('\nDisabled by Default Categories:') ui.PrintMessage('\n'.join('\t%s' % item \ for item in sorted(disabled_by_default_categories))) return 0 if options.systrace_categories in ['list', 'help']: ui.PrintMessage('\n'.join( systrace_controller.SystraceController.GetCategories(device))) return 0 if (perf_controller.PerfProfilerController.IsSupported() and options.perf_categories in ['list', 'help']): ui.PrintMessage('\n'.join( perf_controller.PerfProfilerController.GetCategories(device))) return 0 if not options.time and not options.continuous: ui.PrintMessage( 'Time interval or continuous tracing should be specified.') return 1 chrome_categories = _ComputeChromeCategories(options) systrace_categories = _ComputeSystraceCategories(options) perf_categories = _ComputePerfCategories(options) if chrome_categories and 'webview' in systrace_categories: logging.warning( 'Using the "webview" category in systrace together with ' 'Chrome tracing results in duplicate trace events.') enabled_controllers = [] if chrome_categories: enabled_controllers.append( chrome_controller.ChromeTracingController(device, package_info, chrome_categories, options.ring_buffer, options.trace_memory)) if systrace_categories: enabled_controllers.append( systrace_controller.SystraceController(device, systrace_categories, options.ring_buffer)) if perf_categories: enabled_controllers.append( perf_controller.PerfProfilerController(device, perf_categories)) if options.ddms: enabled_controllers.append( ddms_controller.DdmsController(device, package_info)) if not enabled_controllers: ui.PrintMessage('No trace categories enabled.') return 1 if options.output: options.output = os.path.expanduser(options.output) result = profiler.CaptureProfile( enabled_controllers, options.time if not options.continuous else 0, output=options.output, compress=options.compress, write_json=options.json) if options.view: if sys.platform == 'darwin': os.system('/usr/bin/open %s' % os.path.abspath(result)) else: webbrowser.open(result)
def main(): parser = _CreateOptionParser() options, _args = parser.parse_args() if options.trace_cc: parser.parse_error("""--trace-cc is deprecated. For basic jank busting uses, use --trace-frame-viewer For detailed study of ubercompositor, pass --trace-ubercompositor. When in doubt, just try out --trace-frame-viewer. """) if options.verbose: logging.getLogger().setLevel(logging.DEBUG) devices = android_commands.GetAttachedDevices() if len(devices) != 1: parser.error('Exactly 1 device must be attached.') device = device_utils.DeviceUtils(devices[0]) package_info = profiler.GetSupportedBrowsers()[options.browser] if options.chrome_categories in ['list', 'help']: ui.PrintMessage('Collecting record categories list...', eol='') record_categories = [] disabled_by_default_categories = [] record_categories, disabled_by_default_categories = \ chrome_controller.ChromeTracingController.GetCategories( device, package_info) ui.PrintMessage('done') ui.PrintMessage('Record Categories:') ui.PrintMessage('\n'.join('\t%s' % item \ for item in sorted(record_categories))) ui.PrintMessage('\nDisabled by Default Categories:') ui.PrintMessage('\n'.join('\t%s' % item \ for item in sorted(disabled_by_default_categories))) return 0 if options.systrace_categories in ['list', 'help']: ui.PrintMessage('\n'.join( systrace_controller.SystraceController.GetCategories(device))) return 0 if (perf_controller.PerfProfilerController.IsSupported() and options.perf_categories in ['list', 'help']): ui.PrintMessage('\n'.join( perf_controller.PerfProfilerController.GetCategories(device))) return 0 if not options.time and not options.continuous: ui.PrintMessage( 'Time interval or continuous tracing should be specified.') return 1 chrome_categories = _ComputeChromeCategories(options) systrace_categories = _ComputeSystraceCategories(options) perf_categories = _ComputePerfCategories(options) if chrome_categories and 'webview' in systrace_categories: logging.warning( 'Using the "webview" category in systrace together with ' 'Chrome tracing results in duplicate trace events.') enabled_controllers = [] if chrome_categories: enabled_controllers.append( chrome_controller.ChromeTracingController(device, package_info, chrome_categories, options.ring_buffer, options.trace_memory)) if systrace_categories: enabled_controllers.append( systrace_controller.SystraceController(device, systrace_categories, options.ring_buffer)) if perf_categories: enabled_controllers.append( perf_controller.PerfProfilerController(device, perf_categories)) if not enabled_controllers: ui.PrintMessage('No trace categories enabled.') return 1 if options.output: options.output = os.path.expanduser(options.output) result = profiler.CaptureProfile( enabled_controllers, options.time if not options.continuous else 0, output=options.output, compress=options.compress, write_json=options.json) if options.view_canary: if sys.platform == 'darwin': os.system(( '/usr/bin/open -a /Applications/Google\ Chrome\ Canary.app %s ' '--args --enable-impl-side-painting --enable-skia-benchmarking ' '--allow-webui-compositing') % os.path.abspath(result)) else: _PrintMessage( 'No Chrome Canary on this platform to open trace in, try a different view method' ) elif options.view: if sys.platform == 'darwin': os.system('/usr/bin/open %s' % os.path.abspath(result)) else: webbrowser.open(result) elif options.run_tev and result: os.system('trace-event-viewer %s' % result)