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

Unified Diff: build/android/pylib/perf/test_runner.py

Issue 68173021: Android perf tests: use a proper timer. (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/perf/test_runner.py
diff --git a/build/android/pylib/perf/test_runner.py b/build/android/pylib/perf/test_runner.py
index 48fc6c39617c700e1cdcc515020c44598a9fce28..36cd33729dca0ccdefa2c18cf5c52cb58fff5e20 100644
--- a/build/android/pylib/perf/test_runner.py
+++ b/build/android/pylib/perf/test_runner.py
@@ -46,6 +46,7 @@ import logging
import os
import pickle
import sys
+import threading
import time
from pylib import constants
@@ -88,6 +89,14 @@ class _HeartBeatLogger(object):
"""A file-like class for keeping the buildbot alive."""
self._len = 0
self._tick = time.time()
+ self._stopped = threading.Event()
+ self._timer = threading.Thread(target=self._runner)
+ self._timer.start()
+
+ def _runner(self):
+ while not self._stopped.is_set():
+ self.flush()
+ self._stopped.wait(_HeartBeatLogger._PRINT_INTERVAL)
def write(self, data):
self._len += len(data)
@@ -98,6 +107,9 @@ class _HeartBeatLogger(object):
self._tick = now
print '--single-step output length %d' % self._len
+ def stop(self):
+ self._stopped.set()
+
class TestRunner(base_test_runner.BaseTestRunner):
def __init__(self, test_options, device, tests, flaky_tests):
@@ -173,6 +185,9 @@ class TestRunner(base_test_runner.BaseTestRunner):
full_cmd, cwd=cwd,
withexitstatus=True, logfile=logfile, timeout=timeout,
env=os.environ)
+ if self._options.single_step:
+ # Stop the logger.
+ logfile.stop()
end_time = datetime.datetime.now()
if exit_code is None:
exit_code = -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