aboutsummaryrefslogtreecommitdiff
path: root/crosperf/experiment_status.py
diff options
context:
space:
mode:
authorAhmad Sharif <asharif@chromium.org>2012-02-02 16:37:18 -0800
committerAhmad Sharif <asharif@chromium.org>2012-02-02 16:37:18 -0800
commit0dcbc4b1714260820fd4b8d6536fbb05e139cc0f (patch)
treef8e4825ddcfc2a51f77a504dc371bc67d55fcd8f /crosperf/experiment_status.py
parent70de27bdb5a05716befea67cdf72a87714fcc0da (diff)
downloadtoolchain-utils-0dcbc4b1714260820fd4b8d6536fbb05e139cc0f.tar.gz
Synced repos to: 58208
Diffstat (limited to 'crosperf/experiment_status.py')
-rw-r--r--crosperf/experiment_status.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/crosperf/experiment_status.py b/crosperf/experiment_status.py
new file mode 100644
index 00000000..ddf3f54a
--- /dev/null
+++ b/crosperf/experiment_status.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+# Copyright 2011 Google Inc. All Rights Reserved.
+
+import datetime
+import time
+
+
+class ExperimentStatus(object):
+ def __init__(self, experiment):
+ self.experiment = experiment
+ self.num_total = len(self.experiment.benchmark_runs)
+
+ def _GetProgressBar(self, num_complete, num_total):
+ ret = "Done: %s%%" % int(100.0 * num_complete / num_total)
+ bar_length = 50
+ done_char = ">"
+ undone_char = " "
+ num_complete_chars = bar_length * num_complete / num_total
+ num_undone_chars = bar_length - num_complete_chars
+ ret += " [%s%s]" % (num_complete_chars * done_char, num_undone_chars *
+ undone_char)
+ return ret
+
+ def GetProgressString(self):
+ current_time = time.time()
+ if self.experiment.start_time:
+ elapsed_time = current_time - self.experiment.start_time
+ else:
+ elapsed_time = 0
+ try:
+ eta_seconds = (float(self.num_total - self.experiment.num_complete) *
+ elapsed_time / self.experiment.num_complete)
+ eta_seconds = int(eta_seconds)
+ eta = datetime.timedelta(seconds=eta_seconds)
+ except ZeroDivisionError:
+ eta = "Unknown"
+ strings = []
+ strings.append("Current time: %s Elapsed: %s ETA: %s" %
+ (datetime.datetime.now(),
+ datetime.timedelta(seconds=int(elapsed_time)),
+ eta))
+ strings.append(self._GetProgressBar(self.experiment.num_complete,
+ self.num_total))
+ return "\n".join(strings)
+
+ def GetStatusString(self):
+ status_bins = {}
+ for benchmark_run in self.experiment.benchmark_runs:
+ if benchmark_run.status not in status_bins:
+ status_bins[benchmark_run.status] = []
+ status_bins[benchmark_run.status].append(benchmark_run)
+
+ status_strings = []
+ for key, val in status_bins.items():
+ status_strings.append("%s: %s" %
+ (key, self._GetNamesAndIterations(val)))
+ result = "Thread Status:\n%s" % "\n".join(status_strings)
+
+ # Add the machine manager status.
+ result += "\n" + self.experiment.machine_manager.AsString() + "\n"
+
+ return result
+
+ def _GetNamesAndIterations(self, benchmark_runs):
+ strings = []
+ for benchmark_run in benchmark_runs:
+ strings.append("'%s'" % benchmark_run.name)
+ return " %s (%s)" % (len(strings), ", ".join(strings))