aboutsummaryrefslogtreecommitdiff
path: root/crosperf/experiment_runner_unittest.py
diff options
context:
space:
mode:
authorDenis Nikitin <denik@google.com>2019-10-10 22:31:23 -0700
committerDenis Nikitin <denik@chromium.org>2019-10-16 05:29:14 +0000
commitf94608f33f26b8502fd7c26d0df1e71295d75510 (patch)
treec6247e2fdd306a5408ea2e1897421f81075ea106 /crosperf/experiment_runner_unittest.py
parentbf7ee87429d2c9730349ebc22f904b5a3fac7107 (diff)
downloadtoolchain-utils-f94608f33f26b8502fd7c26d0df1e71295d75510.tar.gz
crosperf: Update top stats and cooldown report
Redirect top statistics from benchmark runs into a separate file topstats.log under results_dir directory. Fix "highest 5" usages to show highest usages of a command (instead of a process) per snapshot. Improve mechanism of calculation chrome high CPU load when benchmark is running. Add Cooldown wait time into email report. Fix minor cros lint warnings to unblock repo upload. BUG=chromium:966514 TEST=unittests and HW tests on eve passed. Change-Id: I3999efd554cb5a3b27a2ce3fddb2f20714b434fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1856818 Tested-by: Denis Nikitin <denik@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'crosperf/experiment_runner_unittest.py')
-rwxr-xr-xcrosperf/experiment_runner_unittest.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/crosperf/experiment_runner_unittest.py b/crosperf/experiment_runner_unittest.py
index caac4265..2ec11ccd 100755
--- a/crosperf/experiment_runner_unittest.py
+++ b/crosperf/experiment_runner_unittest.py
@@ -407,8 +407,11 @@ class ExperimentRunnerTest(unittest.TestCase):
@mock.patch.object(TextResultsReport, 'FromExperiment')
@mock.patch.object(Result, 'CopyResultsTo')
@mock.patch.object(Result, 'CleanUp')
- def test_store_results(self, mock_cleanup, mock_copy, _mock_text_report,
- mock_report, mock_writefile, mock_mkdir, mock_rmdir):
+ @mock.patch.object(Result, 'FormatStringTop5')
+ @mock.patch('__builtin__.open', new_callable=mock.mock_open)
+ def test_store_results(self, mock_open, mock_top5, mock_cleanup, mock_copy,
+ _mock_text_report, mock_report, mock_writefile,
+ mock_mkdir, mock_rmdir):
self.mock_logger.Reset()
self.exp.results_directory = '/usr/local/crosperf-results'
@@ -434,6 +437,8 @@ class ExperimentRunnerTest(unittest.TestCase):
self.assertEqual(mock_mkdir.call_count, 0)
self.assertEqual(mock_rmdir.call_count, 0)
self.assertEqual(self.mock_logger.LogOutputCount, 0)
+ self.assertEqual(mock_open.call_count, 0)
+ self.assertEqual(mock_top5.call_count, 0)
# Test 2. _terminated is false; everything works properly.
fake_result = Result(self.mock_logger, self.exp.labels[0], 'average',
@@ -458,13 +463,24 @@ class ExperimentRunnerTest(unittest.TestCase):
mock_mkdir.assert_called_with('/usr/local/crosperf-results')
self.assertEqual(mock_rmdir.call_count, 1)
mock_rmdir.assert_called_with('/usr/local/crosperf-results')
- self.assertEqual(self.mock_logger.LogOutputCount, 4)
+ self.assertEqual(self.mock_logger.LogOutputCount, 5)
self.assertEqual(self.mock_logger.output_msgs, [
'Storing experiment file in /usr/local/crosperf-results.',
'Storing results report in /usr/local/crosperf-results.',
'Storing email message body in /usr/local/crosperf-results.',
- 'Storing results of each benchmark run.'
+ 'Storing results of each benchmark run.',
+ 'Storing top5 statistics of each benchmark run into'
+ ' /usr/local/crosperf-results/topstats.log.',
])
+ self.assertEqual(mock_open.call_count, 1)
+ # Check write to a topstats.log file.
+ mock_open.assert_called_with('/usr/local/crosperf-results/topstats.log',
+ 'w')
+ mock_open().write.assert_called()
+
+ # Check top5 calls with no arguments.
+ top5calls = [mock.call()] * 6
+ self.assertEqual(mock_top5.call_args_list, top5calls)
if __name__ == '__main__':