Android perf tests: only store the retry results if it's better.

Rather than blindingly store the results of the latest perf test,
keep the "least worst" run.

BUG=

Review URL: https://codereview.chromium.org/27502002

git-svn-id: http://src.chromium.org/svn/trunk/src/build@229351 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
bulach@chromium.org 2013-10-18 11:03:55 +00:00
Родитель 82188be08a
Коммит d7f0c63331
2 изменённых файлов: 23 добавлений и 6 удалений

Просмотреть файл

@ -10,6 +10,7 @@ import logging
import os
import psutil
import signal
import shutil
import time
from pylib import android_commands
@ -58,8 +59,9 @@ def Setup(test_options):
Returns:
A tuple of (TestRunnerFactory, tests).
"""
if not os.path.exists(constants.PERF_OUTPUT_DIR):
os.makedirs(constants.PERF_OUTPUT_DIR)
if os.path.exists(constants.PERF_OUTPUT_DIR):
shutil.rmtree(constants.PERF_OUTPUT_DIR)
os.makedirs(constants.PERF_OUTPUT_DIR)
# Before running the tests, kill any leftover server.
_KillPendingServers()

Просмотреть файл

@ -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
@ -93,11 +93,24 @@ class TestRunner(base_test_runner.BaseTestRunner):
self._tests = tests
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.
@ -133,6 +146,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
@ -144,6 +158,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,