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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 52833002: Purge unpinned ashmem before parsing /proc/$pid/smaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Marcus' comments Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/pylib/utils/host_path_finder.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
11 import datetime 11 import datetime
12 import logging 12 import logging
13 import os 13 import os
14 import re 14 import re
15 import shlex 15 import shlex
16 import signal 16 import signal
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import tempfile 19 import tempfile
20 import time 20 import time
21 21
22 import cmd_helper 22 import cmd_helper
23 import constants 23 import constants
24
25 from utils import host_path_finder
26
24 try: 27 try:
25 from pylib import pexpect 28 from pylib import pexpect
26 except: 29 except:
27 pexpect = None 30 pexpect = None
28 31
29 sys.path.append(os.path.join( 32 sys.path.append(os.path.join(
30 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) 33 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner'))
31 import adb_interface 34 import adb_interface
32 import am_instrument_parser 35 import am_instrument_parser
33 import errors 36 import errors
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 if stats.device == 'mmcblk0': 1405 if stats.device == 'mmcblk0':
1403 return { 1406 return {
1404 'num_reads': stats.num_reads_issued, 1407 'num_reads': stats.num_reads_issued,
1405 'num_writes': stats.num_writes_completed, 1408 'num_writes': stats.num_writes_completed,
1406 'read_ms': stats.ms_spent_reading, 1409 'read_ms': stats.ms_spent_reading,
1407 'write_ms': stats.ms_spent_writing, 1410 'write_ms': stats.ms_spent_writing,
1408 } 1411 }
1409 logging.warning('Could not find disk IO stats.') 1412 logging.warning('Could not find disk IO stats.')
1410 return None 1413 return None
1411 1414
1415 def PurgeUnpinnedAshmem(self):
1416 """Purges the unpinned ashmem memory for the whole system.
1417
1418 This can be used to make memory measurements more stable in particular.
1419 """
1420 host_path = host_path_finder.GetMostRecentHostPath('purge_ashmem')
1421 if host_path:
1422 device_path = os.path.join(constants.TEST_EXECUTABLE_DIR, 'purge_ashmem')
1423 self.PushIfNeeded(host_path, device_path)
1424 if self.RunShellCommand(device_path, log_result=True):
1425 return
1426 logging.error('Could not purge ashmem. Measurement might be unstable.')
frankf 2013/11/05 19:22:56 Generally, we're moving to make these methods more
Philippe 2013/11/06 16:51:09 Done.
1427
1412 def GetMemoryUsageForPid(self, pid): 1428 def GetMemoryUsageForPid(self, pid):
1413 """Returns the memory usage for given pid. 1429 """Returns the memory usage for given pid.
1414 1430
1415 Args: 1431 Args:
1416 pid: The pid number of the specific process running on device. 1432 pid: The pid number of the specific process running on device.
1417 1433
1418 Returns: 1434 Returns:
1419 A tuple containg: 1435 A tuple containg:
1420 [0]: Dict of {metric:usage_kb}, for the process which has specified pid. 1436 [0]: Dict of {metric:usage_kb}, for the process which has specified pid.
1421 The metric keys which may be included are: Size, Rss, Pss, Shared_Clean, 1437 The metric keys which may be included are: Size, Rss, Pss, Shared_Clean,
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 """ 1670 """
1655 def __init__(self, output): 1671 def __init__(self, output):
1656 self._output = output 1672 self._output = output
1657 1673
1658 def write(self, data): 1674 def write(self, data):
1659 data = data.replace('\r\r\n', '\n') 1675 data = data.replace('\r\r\n', '\n')
1660 self._output.write(data) 1676 self._output.write(data)
1661 1677
1662 def flush(self): 1678 def flush(self):
1663 self._output.flush() 1679 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/utils/host_path_finder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698