aboutsummaryrefslogtreecommitdiff
path: root/crosperf/benchmark_run.py
diff options
context:
space:
mode:
authorAhmad Sharif <asharif@chromium.org>2012-05-07 12:02:16 -0700
committerAhmad Sharif <asharif@chromium.org>2012-05-07 12:02:16 -0700
commitfd356fb31c4340851fecc750230d05c9518b125c (patch)
tree694f1a93f568d5e46655c30bb76cb71d7400f11b /crosperf/benchmark_run.py
parent92ab7af223c82fe8897bacea8b32028828eab018 (diff)
downloadtoolchain-utils-fd356fb31c4340851fecc750230d05c9518b125c.tar.gz
Synced repos to: 60208
Diffstat (limited to 'crosperf/benchmark_run.py')
-rw-r--r--crosperf/benchmark_run.py94
1 files changed, 34 insertions, 60 deletions
diff --git a/crosperf/benchmark_run.py b/crosperf/benchmark_run.py
index b2822a4f..f7c37c3f 100644
--- a/crosperf/benchmark_run.py
+++ b/crosperf/benchmark_run.py
@@ -11,6 +11,10 @@ import traceback
from results_cache import Result
from utils import logger
from utils import command_executer
+from autotest_runner import AutotestRunner
+from perf_processor import PerfProcessor
+from results_cache import ResultsCache
+
STATUS_FAILED = "FAILED"
STATUS_SUCCEEDED = "SUCCEEDED"
@@ -24,7 +28,7 @@ class BenchmarkRun(threading.Thread):
def __init__(self, name, benchmark_name, autotest_name, autotest_args,
label_name, chromeos_root, chromeos_image, board, iteration,
cache_conditions, outlier_range, profile_counters, profile_type,
- machine_manager, cache, autotest_runner, perf_processor,
+ machine_manager,
logger_to_use):
threading.Thread.__init__(self)
self.name = name
@@ -37,6 +41,7 @@ class BenchmarkRun(threading.Thread):
self.chromeos_image = os.path.expanduser(chromeos_image)
self.board = board
self.iteration = iteration
+ self.result = None
self.results = {}
self.terminated = False
self.retval = None
@@ -46,9 +51,9 @@ class BenchmarkRun(threading.Thread):
self.profile_counters = profile_counters
self.profile_type = profile_type
self.machine_manager = machine_manager
- self.cache = cache
- self.autotest_runner = autotest_runner
- self.perf_processor = perf_processor
+ self.cache = ResultsCache()
+ self.autotest_runner = AutotestRunner(self._logger)
+ self.perf_processor = None
self.machine = None
self.full_name = self.autotest_name
self.cache_conditions = cache_conditions
@@ -58,58 +63,26 @@ class BenchmarkRun(threading.Thread):
self.failure_reason = ""
self._ce = command_executer.GetCommandExecuter(self._logger)
- def MeanExcludingOutliers(self, array, outlier_range):
- """Return the arithmetic mean excluding outliers."""
- mean = sum(array) / len(array)
- array2 = []
-
- for v in array:
- if mean != 0 and abs(v - mean) / mean < outlier_range:
- array2.append(v)
-
- if array2:
- return sum(array2) / len(array2)
- else:
- return mean
-
- def ParseResults(self, output):
- p = re.compile("^-+.*?^-+", re.DOTALL | re.MULTILINE)
- matches = p.findall(output)
- for i in range(len(matches)):
- results = matches[i]
- results_dict = {}
- for line in results.splitlines()[1:-1]:
- mo = re.match("(.*\S)\s+\[\s+(PASSED|FAILED)\s+\]", line)
- if mo:
- results_dict[mo.group(1)] = mo.group(2)
- continue
- mo = re.match("(.*\S)\s+(.*)", line)
- if mo:
- results_dict[mo.group(1)] = mo.group(2)
-
- return results_dict
- return {}
-
- def ProcessResults(self, result, cache_hit):
+ def ProcessResults(self):
# Generate results from the output file.
- results_dir = self._GetResultsDir(result.out)
- self.full_name = os.path.basename(results_dir)
- self.results = result.keyvals
+ self.full_name = os.path.basename(self.results_dir)
+ self.results = self.result.keyvals
# Store the autotest output in the cache also.
- if not cache_hit:
- self.cache.StoreResult(result)
- self.cache.StoreAutotestOutput(results_dir)
-
+ if not self.cache_hit:
+ self.cache.StoreResult(self.result)
+ self.cache.StoreAutotestOutput(self.results_dir)
+
+ self.perf_processor = PerfProcessor(self.results_dir,
+ self.chromeos_root,
+ self.board,
+ self._logger)
# Generate a perf report and cache it.
if self.profile_type:
- if cache_hit:
+ if self.cache_hit:
self.perf_results = self.cache.ReadPerfResults()
else:
- self.perf_results = (self.perf_processor.
- GeneratePerfResults(results_dir,
- self.chromeos_root,
- self.board))
+ self.perf_results = self.perf_processor.GeneratePerfResults()
self.cache.StorePerfResults(self.perf_results)
# If there are valid results from perf stat, combine them with the
@@ -139,31 +112,32 @@ class BenchmarkRun(threading.Thread):
self.cache_conditions,
self._logger)
- result = self.cache.ReadResult()
- self.cache_hit = (result is not None)
+ self.result = self.cache.ReadResult()
+ self.cache_hit = (self.result is not None)
- if result:
+ if self.result:
self._logger.LogOutput("%s: Cache hit." % self.name)
- self._logger.LogOutput(result.out + "\n" + result.err)
+ self._logger.LogOutput(self.result.out + "\n" + self.result.err)
+ self.results_dir = self._GetResultsDir(self.result.out)
else:
self._logger.LogOutput("%s: No cache hit." % self.name)
self.status = STATUS_WAITING
# Try to acquire a machine now.
self.machine = self.AcquireMachine()
self.cache.remote = self.machine.name
- result = self.RunTest(self.machine)
+ self.result = self.RunTest(self.machine)
if self.terminated:
return
- if not result.retval:
+ if not self.result.retval:
self.status = STATUS_SUCCEEDED
else:
if self.status != STATUS_FAILED:
self.status = STATUS_FAILED
self.failure_reason = "Return value of autotest was non-zero."
- self.ProcessResults(result, self.cache_hit)
+ self.ProcessResults()
except Exception, e:
self._logger.LogError("Benchmark run: '%s' failed: %s" % (self.name, e))
@@ -216,18 +190,18 @@ class BenchmarkRun(threading.Thread):
self.run_completed = True
# Include the keyvals in the result.
- results_dir = self._GetResultsDir(out)
- keyvals = self._GetKeyvals(results_dir)
+ self.results_dir = self._GetResultsDir(out)
+ keyvals = self._GetKeyvals()
keyvals["retval"] = retval
result = Result(out, err, retval, keyvals)
return result
- def _GetKeyvals(self, results_dir):
+ def _GetKeyvals(self):
full_results_dir = os.path.join(self.chromeos_root,
"chroot",
- results_dir.lstrip("/"))
+ self.results_dir.lstrip("/"))
command = "find %s -regex .*results/keyval$" % full_results_dir
[ret, out, err] = self._ce.RunCommand(command, return_output=True)
keyvals_dict = {}