Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: build/android/pylib/device/device_utils.py

Issue 934893002: Revert of [Android] Migrate DeviceUtils.GetMemoryUsageForPid to adb_wrapper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index e89215c43baae38c6f4aa00caa29910a9e9fc464..5dca0e5b8abc6096476c9fdb362676f3e37d72f6 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -8,8 +8,6 @@
"""
# pylint: disable=unused-argument
-import collections
-import itertools
import logging
import multiprocessing
import os
@@ -1308,54 +1306,14 @@
retries: number of retries
Returns:
- A dict containing memory usage statistics for the PID. May include:
- Size, Rss, Pss, Shared_Clean, Shared_Dirty, Private_Clean,
- Private_Dirty, VmHWM
-
- Raises:
- CommandTimeoutError on timeout.
- """
- result = collections.defaultdict(int)
-
- try:
- result.update(self._GetMemoryUsageForPidFromSmaps(pid))
- except device_errors.CommandFailedError:
- logging.exception('Error getting memory usage from smaps')
-
- try:
- result.update(self._GetMemoryUsageForPidFromStatus(pid))
- except device_errors.CommandFailedError:
- logging.exception('Error getting memory usage from status')
-
- return result
-
- def _GetMemoryUsageForPidFromSmaps(self, pid):
- SMAPS_COLUMNS = (
- 'Size', 'Rss', 'Pss', 'Shared_Clean', 'Shared_Dirty', 'Private_Clean',
- 'Private_Dirty')
-
- showmap_out = self.RunShellCommand(
- ['showmap', str(pid)], as_root=True, check_return=True)
- if not showmap_out:
- raise device_errors.CommandFailedError('No output from showmap')
-
- split_totals = showmap_out[-1].split()
- if (not split_totals
- or len(split_totals) != 9
- or split_totals[-1] != 'TOTAL'):
- raise device_errors.CommandFailedError(
- 'Invalid output from showmap: %s' % '\n'.join(showmap_out))
-
- return dict(itertools.izip(SMAPS_COLUMNS, (int(n) for n in split_totals)))
-
- def _GetMemoryUsageForPidFromStatus(self, pid):
- for line in self.ReadFile(
- '/proc/%s/status' % str(pid), as_root=True).splitlines():
- if line.startswith('VmHWM:'):
- return {'VmHWM': int(line.split()[1])}
- else:
- raise device_errors.CommandFailedError(
- 'Could not find memory peak value for pid %s', str(pid))
+ A 2-tuple containing:
+ - A dict containing the overall memory usage statistics for the PID.
+ - A dict containing memory usage statistics broken down by mapping.
+
+ Raises:
+ CommandTimeoutError on timeout.
+ """
+ return self.old_interface.GetMemoryUsageForPid(pid)
@decorators.WithTimeoutAndRetriesFromInstance()
def GetLogcatMonitor(self, timeout=None, retries=None, *args, **kwargs):
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698