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..1494af6e1878f498abb78bcfbce25dc9da97d02a 100644 |
--- a/build/android/pylib/perf/test_runner.py |
+++ b/build/android/pylib/perf/test_runner.py |
@@ -47,6 +47,7 @@ import datetime |
import logging |
import pickle |
import os |
+import re |
Dominik Grewe
2013/10/16 13:51:43
Is this needed for anything?
bulach
2013/10/16 17:03:01
nope, removed..
|
import sys |
from pylib import constants |
@@ -96,10 +97,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 +149,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 +161,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, |