aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yardstick/benchmark/core/report.py31
-rw-r--r--yardstick/tests/unit/benchmark/core/test_report.py142
2 files changed, 173 insertions, 0 deletions
diff --git a/yardstick/benchmark/core/report.py b/yardstick/benchmark/core/report.py
index 3d5912471..587c85a14 100644
--- a/yardstick/benchmark/core/report.py
+++ b/yardstick/benchmark/core/report.py
@@ -305,6 +305,37 @@ class Report(object):
print("Report generated. View %s" % consts.DEFAULT_HTML_FILE)
+ def _combine_times(self, *args):
+ times = []
+ # Combines an arbitrary number of lists
+ [times.extend(x) for x in args]
+ times = list(set(times))
+ times.sort()
+ return times
+
+ def _combine_metrics(self, *args):
+ baro_data, baro_time, yard_data, yard_time = args
+ combo_time = self._combine_times(baro_time, yard_time)
+
+ data = {}
+ [data.update(x) for x in (baro_data, yard_data)]
+
+ table_data = {}
+ table_data['Timestamp'] = combo_time
+ combo = {}
+ keys = sorted(data.keys())
+ for met_name in data:
+ dataset = []
+ for point in data[met_name]:
+ dataset.append({'x': point, 'y': data[met_name][point]})
+ # the metrics need to be ordered by time
+ combo[met_name] = sorted(dataset, key=lambda i: i['x'])
+ for met_name in data:
+ table_data[met_name] = []
+ for t in combo_time:
+ table_data[met_name].append(data[met_name].get(t, ''))
+ return combo, keys, table_data
+
@cliargs("task_id", type=str, help=" task id", nargs=1)
@cliargs("yaml_name", type=str, help=" Yaml file Name", nargs=1)
def generate_nsb(self, args):
diff --git a/yardstick/tests/unit/benchmark/core/test_report.py b/yardstick/tests/unit/benchmark/core/test_report.py
index a92eda1b8..f3b17f30a 100644
--- a/yardstick/tests/unit/benchmark/core/test_report.py
+++ b/yardstick/tests/unit/benchmark/core/test_report.py
@@ -388,6 +388,148 @@ class ReportTestCase(unittest.TestCase):
self.rep._format_datasets(metric_name, metrics)
)
+ def test__combine_times(self):
+ yard_times = [
+ '00:00:00.000000',
+ '00:00:01.000000',
+ '00:00:02.000000',
+ '00:00:06.000000',
+ '00:00:08.000000',
+ '00:00:09.000000',
+ ]
+ baro_times = [
+ '00:00:01.000000',
+ '00:00:03.000000',
+ '00:00:04.000000',
+ '00:00:05.000000',
+ '00:00:07.000000',
+ '00:00:10.000000',
+ ]
+ expected_combo = [
+ '00:00:00.000000',
+ '00:00:01.000000',
+ '00:00:02.000000',
+ '00:00:03.000000',
+ '00:00:04.000000',
+ '00:00:05.000000',
+ '00:00:06.000000',
+ '00:00:07.000000',
+ '00:00:08.000000',
+ '00:00:09.000000',
+ '00:00:10.000000',
+ ]
+
+ actual_combo = self.rep._combine_times(yard_times, baro_times)
+ self.assertEqual(len(expected_combo), len(actual_combo))
+
+ self.assertEqual(
+ expected_combo,
+ actual_combo,
+ )
+
+ def test__combine_times_2(self):
+ time1 = ['14:11:25.383698', '14:11:25.383712', '14:11:35.383696',]
+ time2 = [
+ '16:20:14.568075', '16:20:24.575083',
+ '16:20:34.580989', '16:20:44.586801', ]
+ time_exp = [
+ '14:11:25.383698', '14:11:25.383712', '14:11:35.383696',
+ '16:20:14.568075', '16:20:24.575083', '16:20:34.580989',
+ '16:20:44.586801',
+ ]
+ self.assertEqual(time_exp, self.rep._combine_times(time1, time2))
+
+ def test__combine_metrics(self):
+ BARO_METRICS = {
+ 'myhostname.cpu_value.cpu.user.0': {
+ '14:11:25.3836': 324050, '14:11:35.3836': 324051,
+ '14:11:45.3836': 324054,
+ },
+ 'myhostname.cpu_value.cpu.system.0': {
+ '14:11:25.3837': 193798, '14:11:35.3837': 193800,
+ '14:11:45.3837': 193801,
+ }
+ }
+ BARO_TIMES = [
+ '14:11:25.3836', '14:11:25.3837', '14:11:35.3836',
+ '14:11:35.3837', '14:11:45.3836', '14:11:45.3837',
+ ]
+ YARD_METRICS = {
+ 'free.memory9.free': {
+ '16:20:14.5680': 1958244, '16:20:24.5750': 1955964,
+ '16:20:34.5809': 1956040, '16:20:44.5868': 1956428,
+ },
+ 'free.memory7.used': {
+ '16:20:14.5680': 9789068, '16:20:24.5750': 9791284,
+ '16:20:34.5809': 9791228, '16:20:44.5868': 9790692,
+ },
+ 'free.memory2.total':{
+ '16:20:14.5680': 32671288, '16:20:24.5750': 32671288,
+ '16:20:34.5809': 32671288, '16:20:44.5868': 32671288,
+ },
+ 'free.memory7.free': {
+ '16:20:14.5680': 1958368, '16:20:24.5750': 1956104,
+ '16:20:34.5809': 1956040, '16:20:44.5868': 1956552,
+ },
+ 'free.memory1.used': {
+ '16:20:14.5680': 9788872, '16:20:24.5750': 9789212,
+ '16:20:34.5809': 9791168, '16:20:44.5868': 9790996,
+ },
+ }
+ YARD_TIMES = [
+ '16:20:14.5680', '16:20:24.5750',
+ '16:20:34.5809', '16:20:44.5868',
+ ]
+
+ expected_output = {
+ 'myhostname.cpu_value.cpu.user.0': [{
+ 'x': '14:11:25.3836', 'y': 324050, }, {
+ 'x': '14:11:35.3836', 'y': 324051, }, {
+ 'x': '14:11:45.3836', 'y': 324054, }],
+ 'myhostname.cpu_value.cpu.system.0' : [{
+ 'x': '14:11:25.3837', 'y': 193798, }, {
+ 'x': '14:11:35.3837', 'y': 193800, }, {
+ 'x': '14:11:45.3837', 'y': 193801, }],
+ 'free.memory9.free': [{
+ 'x': '16:20:14.5680', 'y': 1958244, }, {
+ 'x': '16:20:24.5750', 'y': 1955964, }, {
+ 'x': '16:20:34.5809', 'y': 1956040, }, {
+ 'x': '16:20:44.5868', 'y': 1956428, }],
+ 'free.memory7.used': [{
+ 'x': '16:20:14.5680', 'y': 9789068, }, {
+ 'x': '16:20:24.5750', 'y': 9791284, }, {
+ 'x': '16:20:34.5809', 'y': 9791228, }, {
+ 'x': '16:20:44.5868', 'y': 9790692, }],
+ 'free.memory2.total': [{
+ 'x': '16:20:14.5680', 'y': 32671288, }, {
+ 'x': '16:20:24.5750', 'y': 32671288, }, {
+ 'x': '16:20:34.5809', 'y': 32671288, }, {
+ 'x': '16:20:44.5868', 'y': 32671288, }],
+ 'free.memory7.free': [{
+ 'x': '16:20:14.5680', 'y': 1958368, }, {
+ 'x': '16:20:24.5750', 'y': 1956104, }, {
+ 'x': '16:20:34.5809', 'y': 1956040, }, {
+ 'x': '16:20:44.5868', 'y': 1956552, }],
+ 'free.memory1.used': [{
+ 'x': '16:20:14.5680', 'y': 9788872, }, {
+ 'x': '16:20:24.5750', 'y': 9789212, }, {
+ 'x': '16:20:34.5809', 'y': 9791168, }, {
+ 'x': '16:20:44.5868', 'y': 9790996, }],
+ }
+
+ actual_output, _, _ = self.rep._combine_metrics(
+ BARO_METRICS, BARO_TIMES, YARD_METRICS, YARD_TIMES
+ )
+ self.assertEquals(
+ sorted(expected_output.keys()),
+ sorted(actual_output.keys())
+ )
+
+ self.assertEquals(
+ expected_output,
+ actual_output,
+ )
+
@mock.patch.object(report.Report, '_get_metrics')
@mock.patch.object(report.Report, '_get_fieldkeys')
def test__generate_common(self, mock_keys, mock_metrics):