def __init__(self, browser_backend, platform_backend, output_path, state): super(PerfProfiler, self).__init__(browser_backend, platform_backend, output_path, state) process_output_file_map = self._GetProcessOutputFileMap() self._process_profilers = [] self._perf_control = None perf_binary = perfhost_binary = _InstallPerfHost() try: if platform_backend.GetOSName() == 'android': device = browser_backend.device perf_binary = android_profiling_helper.PrepareDeviceForPerf( device) self._perf_control = perf_control.PerfControl(device) self._perf_control.SetPerfProfilingMode() else: _PrepareHostForPerf() for pid, output_file in process_output_file_map.iteritems(): if 'zygote' in output_file: continue self._process_profilers.append( _SingleProcessPerfProfiler(pid, output_file, browser_backend, platform_backend, perf_binary, perfhost_binary)) except: if self._perf_control: self._perf_control.SetDefaultPerfMode() raise
self._categories = None def __repr__(self): return 'perf profile' @staticmethod def IsSupported(): return bool(android_profiling_helper) @staticmethod def _PrepareDevice(presentation.device): if not 'BUILDTYPE' in os.environ: os.environ['BUILDTYPE'] = 'Release' if binary_manager.NeedsInit(): binary_manager.InitDependencyManager(None) return android_profiling_helper.PrepareDeviceForPerf(presentation.device) @classmethod def GetCategories(cls, presentation.device): perf_binary = cls._PrepareDevice(presentation.device) # Perf binary returns non-zero exit status on "list" command. return presentation.device.RunShellCommand([perf_binary, 'list'], check_return=False) @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) def StartAgentTracing(self, config, timeout=None): self._categories = _ComputePerfCategories(config) self._perf_instance = _PerfProfiler(self._device, self._perf_binary, self._categories) return True
def _PrepareDevice(device): if not 'BUILDTYPE' in os.environ: os.environ['BUILDTYPE'] = 'Release' binary_manager.InitDependencyManager(None) return android_profiling_helper.PrepareDeviceForPerf(device)
def _PrepareDevice(device): if not 'BUILDTYPE' in os.environ: os.environ['BUILDTYPE'] = 'Release' return android_profiling_helper.PrepareDeviceForPerf(device)