def testTracing(self): agent = ddms_tracing_agent.DdmsAgent(self.device, self.package_info) try: agent.StartAgentTracing(None) finally: agent.StopAgentTracing() result = agent.GetResults() self.assertTrue(result.raw_data.startswith('*version'))
def main(): parser = _CreateOptionParser() options, _args = parser.parse_args() # pylint: disable=unused-variable if options.trace_cc: parser.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) device = device_utils.DeviceUtils.HealthyDevices( device_arg=options.device)[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_tracing_agent.ChromeTracingAgent.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.atrace_categories in ['list', 'help']: ui.PrintMessage('\n'.join( atrace_tracing_agent.AtraceAgent.GetCategories(device))) return 0 if (perf_tracing_agent.PerfProfilerAgent.IsSupported() and options.perf_categories in ['list', 'help']): ui.PrintMessage('\n'.join( perf_tracing_agent.PerfProfilerAgent.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) atrace_categories = _ComputeAtraceCategories(options) perf_categories = _ComputePerfCategories(options) if chrome_categories and 'webview' in atrace_categories: logging.warning('Using the "webview" category in atrace together with ' 'Chrome tracing results in duplicate trace events.') enabled_agents = [] if chrome_categories: enabled_agents.append( chrome_tracing_agent.ChromeTracingAgent(device, package_info, chrome_categories, options.ring_buffer, options.trace_memory)) if atrace_categories: enabled_agents.append( atrace_tracing_agent.AtraceAgent(device, atrace_categories, options.ring_buffer)) if perf_categories: enabled_agents.append( perf_tracing_agent.PerfProfilerAgent(device, perf_categories)) if options.ddms: enabled_agents.append( ddms_tracing_agent.DdmsAgent(device, package_info)) if not enabled_agents: ui.PrintMessage('No trace categories enabled.') return 1 if options.output: options.output = os.path.expanduser(options.output) result = profiler.CaptureProfile( enabled_agents, 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)