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

Unified Diff: build/android/pylib/android_commands.py

Issue 97133002: Add instance-level in-memory cache for PushIfNeeded(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 8d8949cac74c8db343ff68b5c9a33da11d462bf8..fe9f7533d4db36cf5f90c67c6a04c2b79c127365 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -253,6 +253,7 @@ class AndroidCommands(object):
self._actual_push_size = 0
self._external_storage = ''
self._util_wrapper = ''
+ self._push_if_needed_cache = {}
def _LogShell(self, cmd):
"""Logs the adb shell command."""
@@ -917,6 +918,14 @@ class AndroidCommands(object):
MAX_INDIVIDUAL_PUSHES = 50
assert os.path.exists(host_path), 'Local path not found %s' % host_path
+ # See if the file on the host changed since the last push (if any) and
+ # return early if it didn't. Note that this shortcut assumes that the tests
+ # on the device don't modify the files.
+ if host_path in self._push_if_needed_cache:
craigdh 2013/12/02 17:09:36 What about when |host_path| is a directory? Updati
Philippe 2013/12/02 17:16:43 Good catch :) I had forgotten that |host_path| cou
craigdh 2013/12/02 18:20:19 It should be pretty easy to do with os.walk(). Do
Philippe 2013/12/03 10:31:31 My main concern was precisely that I have no immed
+ host_path_mtime = self._push_if_needed_cache[host_path]
+ if host_path_mtime == os.stat(host_path).st_mtime:
+ return
+
def GetHostSize(path):
return int(cmd_helper.GetCmdOutput(['du', '-sb', path]).split()[0])
@@ -941,6 +950,7 @@ class AndroidCommands(object):
while True:
output = self._adb.SendCommand(push_command, timeout_time=30 * 60)
if _HasAdbPushSucceeded(output):
+ self._push_if_needed_cache[host] = os.stat(host).st_mtime
return
if retry < 3:
retry += 1
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698