Index: build/android/pylib/android_commands.py |
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py |
index 1741619276ce56042a9a3df6f3b004fed1ebe3ad..739d9be3efe40a555f326db26a78c3e5662082b4 100644 |
--- a/build/android/pylib/android_commands.py |
+++ b/build/android/pylib/android_commands.py |
@@ -1409,6 +1409,59 @@ class AndroidCommands(object): |
logging.warning('Could not find disk IO stats.') |
return None |
+ @staticmethod |
+ def _GetExistingHostOutputPath(file_name): |
frankf
2013/11/04 18:17:06
If you decide to keep this, it should be moved to
|
+ """Returns the most likely correct full path for the given file name. |
+ |
+ Returns: The full path that was found or throws an exception if no path |
+ could be found. |
+ """ |
+ candidate_path = None |
+ build_type = None |
+ out_dir = os.path.join( |
+ constants.DIR_SOURCE_ROOT, os.environ.get('CHROMIUM_OUT_DIR', 'out')) |
+ |
+ if constants.BuildTypeIsSet(): |
Philippe
2013/10/30 17:18:21
FYI, this condition is not always met which is why
craigdh
2013/10/31 00:10:13
My understanding is that the goal is to support ar
Philippe
2013/11/04 14:45:55
I will let Marcus comment on this :)
|
+ candidate_path = os.path.join( |
+ out_dir, constants.GetBuildType(), file_name) |
+ else: |
+ release_path = os.path.join(out_dir, 'Release', file_name) |
+ debug_path = os.path.join(out_dir, 'Debug', file_name) |
+ |
+ if os.path.exists(release_path): |
+ if os.path.exists(debug_path): |
+ # Retain the most recent file. |
+ release_path_mtime = time.ctime(os.path.getmtime(release_path)) |
+ debug_path_mtime = time.ctime(os.path.getmtime(debug_path)) |
+ if release_path_mtime > debug_path_mtime: |
+ constants.SetBuildType('Release') |
+ return release_path |
+ constants.SetBuildType('Debug') |
+ return debug_path |
+ candidate_path = release_path |
+ build_type = 'Release' |
+ else: |
+ candidate_path = debug_path |
+ build_type = 'Debug' |
digit1
2013/11/04 14:15:55
I'm ok with self-detection, but if you don't plan
Philippe
2013/11/04 14:45:55
Yeah good idea. We got bitten more than once with
|
+ |
+ if not os.path.exists(candidate_path): |
+ raise Exception('File %s does not exist' % candidate_path) |
+ |
+ if build_type: |
+ constants.SetBuildType(build_type) |
+ return candidate_path |
+ |
+ def _PurgeUnpinnedAshmem(self): |
+ """Purges the unpinned ashmem memory for the whole system. |
+ |
+ This can be used to make memory measurements more stable in particular. |
+ """ |
+ host_path = AndroidCommands._GetExistingHostOutputPath('purge_ashmem') |
+ device_path = os.path.join(constants.TEST_EXECUTABLE_DIR, 'purge_ashmem') |
+ self.PushIfNeeded(host_path, device_path) |
+ if not self.RunShellCommand(device_path, log_result=True): |
+ logging.warning('Could not purge ashmem. Measurement might be unstable.') |
+ |
def GetMemoryUsageForPid(self, pid): |
"""Returns the memory usage for given pid. |
@@ -1425,6 +1478,7 @@ class AndroidCommands(object): |
""" |
usage_dict = collections.defaultdict(int) |
smaps = collections.defaultdict(dict) |
+ self._PurgeUnpinnedAshmem() |
tonyg
2013/11/03 05:05:18
Telemetry calls GetMemoryUsageForPid, and before w
Philippe
2013/11/04 14:45:55
Thanks for the instructions Tony. I have just push
|
current_smap = '' |
for line in self.GetProtectedFileContents('/proc/%s/smaps' % pid, |
log_result=False): |