aboutsummaryrefslogtreecommitdiff
path: root/crosperf/benchmark_run.py
diff options
context:
space:
mode:
authorDenis Nikitin <denik@google.com>2019-09-27 09:04:31 -0700
committerDenis Nikitin <denik@chromium.org>2019-09-28 04:29:49 +0000
commit30a061f7921c173e9a25a940319a7f79e41c98ec (patch)
treefbf41a5066384a85948831e0168b892d4f927eab /crosperf/benchmark_run.py
parent4713fd1d6e502969ab8690adb513d8d00973ac44 (diff)
downloadtoolchain-utils-30a061f7921c173e9a25a940319a7f79e41c98ec.tar.gz
crosperf: Print top5 commands into log
Enable top in nightly tests and print top 5 commands with high CPU usage into log. BUG=chromium:966514 TEST=unittests and HW tests on eve passed. Change-Id: I0efd7f0875829c4423e998ec2fbec7436f7ae148 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1829309 Tested-by: Denis Nikitin <denik@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'crosperf/benchmark_run.py')
-rw-r--r--crosperf/benchmark_run.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/crosperf/benchmark_run.py b/crosperf/benchmark_run.py
index fd2f857b..0147599d 100644
--- a/crosperf/benchmark_run.py
+++ b/crosperf/benchmark_run.py
@@ -91,6 +91,25 @@ class BenchmarkRun(threading.Thread):
self.cache_hit = (self.result is not None)
self.cache_has_been_read = True
+ def PrintTop5Cmds(self, topcmds):
+ """Print top 5 commands into log."""
+
+ self._logger.LogOutput('%s' % str(self))
+ self._logger.LogOutput('Top 5 commands with highest CPU usage:')
+ # Header.
+ print_line = '%20s %9s %6s %s' % ('COMMAND', 'AVG CPU%', 'COUNT',
+ 'HIGHEST 5')
+ self._logger.LogOutput(print_line)
+ self._logger.LogOutput('-' * 50)
+ if topcmds:
+ for topcmd in topcmds[:5]:
+ print_line = '%20s %9.2f %6s %s' % (topcmd['cmd'], topcmd['cpu_avg'],
+ topcmd['count'], topcmd['top5'])
+ self._logger.LogOutput(print_line)
+ else:
+ self._logger.LogOutput('[NO DATA FROM THE TOP LOG]')
+ self._logger.LogOutput('-' * 50)
+
def run(self):
try:
if not self.cache_has_been_read:
@@ -118,6 +137,9 @@ class BenchmarkRun(threading.Thread):
self.machine = self.AcquireMachine()
self.cache.machine = self.machine
self.result = self.RunTest(self.machine)
+ # TODO(denik): Add Top5 report into html.
+ if self.result:
+ self.PrintTop5Cmds(self.result.GetTopCmds())
self.cache.remote = self.machine.name
self.label.chrome_version = self.machine_manager.GetChromeVersion(