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

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

Issue 14767023: Speedup net_unittests on Android by 30%. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/chrome_test_server_spawner.py
diff --git a/build/android/pylib/chrome_test_server_spawner.py b/build/android/pylib/chrome_test_server_spawner.py
index 676939bc17d34b3aed4bcc287609af929f9b2b05..7f24ffb1968b5671387f75676c7f4ddfd473650e 100644
--- a/build/android/pylib/chrome_test_server_spawner.py
+++ b/build/android/pylib/chrome_test_server_spawner.py
@@ -45,6 +45,7 @@ SERVER_TYPES = {
# The timeout (in seconds) of starting up the Python test server.
TEST_SERVER_STARTUP_TIMEOUT = 10
+INITIAL_SLEEP_TIMEOUT_SEC = 0.025
def _CheckPortStatus(port, expected_status):
"""Returns True if port has expected_status.
@@ -56,10 +57,12 @@ def _CheckPortStatus(port, expected_status):
Returns:
Returns True if the status is expected. Otherwise returns False.
"""
- for timeout in range(1, 5):
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC
+ for attempt in range(1, 5):
if ports.IsHostPortUsed(port) == expected_status:
return True
- time.sleep(timeout)
+ time.sleep(sleep_time_sec)
+ sleep_time_sec *= 2
return False
@@ -231,17 +234,21 @@ class TestServerThread(threading.Thread):
device_port = self._test_server_forwarder.DevicePortForHostPort(
self.host_port)
if device_port:
- for timeout in range(1, 5):
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC
+ for attempt in range(1, 5):
if ports.IsDevicePortUsed(self.adb, device_port, 'LISTEN'):
self.is_ready = True
self.forwarder_device_port = device_port
break
- time.sleep(timeout)
+ time.sleep(sleep_time_sec)
+ sleep_time_sec *= 2
bulach 2013/05/07 15:09:28 perhaps move this out into a "_CheckDevicePortStat
Philippe 2013/05/07 15:47:41 Good idea. I would not encourage people to use thi
# Wake up the request handler thread.
self.ready_event.set()
# Keep thread running until Stop() gets called.
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC
while not self.stop_flag:
- time.sleep(1)
+ time.sleep(sleep_time_sec)
+ sleep_time_sec *= 2
bulach 2013/05/07 15:09:28 should we limit this somehow up to say, 1 or two s
Philippe 2013/05/07 15:47:41 Yeah good point.
if self.process.poll() is None:
self.process.kill()
if self._test_server_forwarder:
@@ -401,7 +408,6 @@ class SpawningServer(object):
listener_thread = threading.Thread(target=self._Listen)
listener_thread.setDaemon(True)
listener_thread.start()
- time.sleep(1)
def Stop(self):
"""Stops the test server spawner.
« 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