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 c1ad07f7c55c005fd521d16f48c937de12ffcf02..2225223766ad1645c93748fc50531b7b34ffb911 100644 |
--- a/build/android/pylib/perf/test_runner.py |
+++ b/build/android/pylib/perf/test_runner.py |
@@ -2,7 +2,7 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-"""Runs a perf test on a single device. |
+"""Runs perf tests. |
Our buildbot infrastructure requires each slave to run steps serially. |
This is sub-optimal for android, where these steps can run independently on |
@@ -96,10 +96,23 @@ class TestRunner(base_test_runner.BaseTestRunner): |
self._flaky_tests = flaky_tests |
@staticmethod |
+ def _IsBetter(result): |
+ if result['actual_exit_code'] == 0: |
+ return True |
+ pickled = os.path.join(constants.PERF_OUTPUT_DIR, |
+ result['name']) |
+ if not os.path.exists(pickled): |
+ return True |
+ with file(pickled, 'r') as f: |
+ previous = pickle.loads(f.read()) |
+ return result['actual_exit_code'] < previous['actual_exit_code'] |
+ |
+ @staticmethod |
def _SaveResult(result): |
- with file(os.path.join(constants.PERF_OUTPUT_DIR, |
- result['name']), 'w') as f: |
- f.write(pickle.dumps(result)) |
+ if TestRunner._IsBetter(result): |
+ with file(os.path.join(constants.PERF_OUTPUT_DIR, |
+ result['name']), 'w') as f: |
+ f.write(pickle.dumps(result)) |
def _LaunchPerfTest(self, test_name): |
"""Runs a perf test. |
@@ -135,6 +148,7 @@ class TestRunner(base_test_runner.BaseTestRunner): |
result_type = base_test_result.ResultType.FAIL |
if exit_code == 0: |
result_type = base_test_result.ResultType.PASS |
+ actual_exit_code = exit_code |
if test_name in self._flaky_tests: |
# The exit_code is used at the second stage when printing the |
# test output. If the test is flaky, force to "0" to get that step green |
@@ -146,6 +160,7 @@ class TestRunner(base_test_runner.BaseTestRunner): |
'name': test_name, |
'output': output, |
'exit_code': exit_code, |
+ 'actual_exit_code': actual_exit_code, |
'result_type': result_type, |
'total_time': (end_time - start_time).seconds, |
'device': self.device, |