def __init__(self, adb): super(DS2784PowerMonitor, self).__init__() self._adb = adb self._powermonitor_process_port = None android_prebuilt_profiler_helper.InstallOnDevice(adb, 'file_poller') self._file_poller_binary = android_prebuilt_profiler_helper.GetDevicePath( 'file_poller')
def StartMonitoringPower(self, browser): assert not self._powermonitor_process_port, ( 'Must call StopMonitoringPower().') android_prebuilt_profiler_helper.InstallOnDevice( self._device, 'file_poller') self._powermonitor_process_port = int( self._device.RunShellCommand( '%s %d %s %s %s' % (self._file_poller_binary, SAMPLE_RATE_HZ, CHARGE_COUNTER, CURRENT, VOLTAGE))[0])
def __init__(self, browser_backend, platform_backend, output_path, state): super(TCPDumpProfiler, self).__init__( browser_backend, platform_backend, output_path, state) if platform_backend.GetOSName() == 'android': android_prebuilt_profiler_helper.InstallOnDevice( browser_backend.adb, 'tcpdump') self._platform_profiler = _TCPDumpProfilerAndroid( browser_backend.adb, output_path) else: self._platform_profiler = _TCPDumpProfilerLinux(output_path)
def PurgeUnpinnedMemory(self): """Purges the unpinned ashmem memory for the whole system. This can be used to make memory measurements more stable in particular. """ android_prebuilt_profiler_helper.InstallOnDevice( self._adb, 'purge_ashmem') if self._adb.RunShellCommand( android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem'), log_result=True): return raise Exception('Error while purging ashmem.')
def PrepareDeviceForPerf(device): """Set up a device for running perf. Args: device: DeviceUtils instance identifying the target device. Returns: The path to the installed perf binary on the device. """ android_prebuilt_profiler_helper.InstallOnDevice(device, 'perf') # Make sure kernel pointers are not hidden. device.WriteFile('/proc/sys/kernel/kptr_restrict', '0', as_root=True) return android_prebuilt_profiler_helper.GetDevicePath('perf')
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 = [] if platform_backend.GetOSName() == 'android': android_prebuilt_profiler_helper.GetIfChanged('perfhost') os.chmod(android_prebuilt_profiler_helper.GetHostPath('perfhost'), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) android_prebuilt_profiler_helper.InstallOnDevice( browser_backend.adb, 'perf') 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))
def PurgeUnpinnedMemory(self): """Purges the unpinned ashmem memory for the whole system. This can be used to make memory measurements more stable. Requires root. """ if not self._can_access_protected_file_contents: logging.warning('Cannot run purge_ashmem. Requires a rooted device.') return if not android_prebuilt_profiler_helper.InstallOnDevice( self._device, 'purge_ashmem'): raise Exception('Error installing purge_ashmem.') output = self._device.RunShellCommand( android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem'), check_return=True) for l in output: logging.info(l)
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 = [] if platform_backend.GetOSName() == 'android': android_prebuilt_profiler_helper.InstallOnDevice( browser_backend.adb.Adb(), 'perf') # Make sure kernel pointers are not hidden. browser_backend.adb.Adb().SetProtectedFileContents( '/proc/sys/kernel/kptr_restrict', '0') 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))
def PurgeUnpinnedMemory(self): """Purges the unpinned ashmem memory for the whole system. This can be used to make memory measurements more stable. Requires root. """ if not self._can_access_protected_file_contents: logging.warning( 'Cannot run purge_ashmem. Requires a rooted device.') return if not android_prebuilt_profiler_helper.InstallOnDevice( self._device, 'purge_ashmem'): raise Exception('Error installing purge_ashmem.') (status, output) = self._device.old_interface.GetAndroidToolStatusAndOutput( android_prebuilt_profiler_helper.GetDevicePath('purge_ashmem'), log_result=True) if status != 0: raise Exception('Error while purging ashmem: ' + '\n'.join(output))