| Index: tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| index a0f82299564a55b3fdb717e2bf233744918767e6..9377e46415d8bc198ca597fbbeaef5f9d68a00b5 100644
|
| --- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| +++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
|
| @@ -11,6 +11,7 @@ from telemetry.core import exceptions
|
| from telemetry.core import platform
|
| from telemetry.core import util
|
| from telemetry.core.platform import proc_supporting_platform_backend
|
| +from telemetry.core.platform.profiler import android_prebuilt_profiler_helper
|
|
|
| # Get build/android scripts into our path.
|
| util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'build', 'android')
|
| @@ -109,8 +110,19 @@ class AndroidPlatformBackend(
|
| return {}
|
| return super(AndroidPlatformBackend, self).GetCpuTimestamp()
|
|
|
| + 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 GetMemoryStats(self, pid):
|
| - self._adb.PurgeUnpinnedAshmem()
|
| memory_usage = self._adb.GetMemoryUsageForPid(pid)[0]
|
| return {'ProportionalSetSize': memory_usage['Pss'] * 1024,
|
| 'SharedDirty': memory_usage['Shared_Dirty'] * 1024,
|
|
|