Report: Fix Oper data
[csit.git] / resources / tools / presentation / input_data_parser.py
index ddfd96c..7c9cd30 100644 (file)
@@ -30,6 +30,8 @@ from datetime import datetime as dt
 from datetime import timedelta
 from json import loads
 
+import hdrh.histogram
+import hdrh.codec
 import prettytable
 import pandas as pd
 
@@ -315,6 +317,8 @@ class ExecutionChecker(ResultVisitor):
         # 2 - PAPI History of DUT2
         self._conf_history_lookup_nr = 0
 
+        self._sh_run_counter = 0
+
         # Test ID of currently processed test- the lowercase full path to the
         # test
         self._test_id = None
@@ -398,39 +402,78 @@ class ExecutionChecker(ResultVisitor):
         except (AttributeError, IndexError, ValueError, KeyError):
             return msg
 
-        def _process_lat(in_str):
+        def _process_lat(in_str_1, in_str_2):
             """Extract min, avg, max values from latency string.
 
-            :param in_str: Latency string produced by robot framework.
-            :type in_str: str
+            :param in_str_1: Latency string for one direction produced by robot
+                framework.
+            :param in_str_2: Latency string for second direction produced by
+                robot framework.
+            :type in_str_1: str
+            :type in_str_2: str
             :returns: Processed latency string or original string if a problem
                 occurs.
-            :rtype: str
+            :rtype: tuple(str, str)
             """
-            in_list = in_str.split('/', 3)
-            if len(in_list) < 3:
-                return in_str
+            in_list_1 = in_str_1.split('/', 3)
+            if len(in_list_1) < 3:
+                return u"Not Measured.", u"Not Measured."
+
+            in_list_2 = in_str_2.split('/', 3)
+            if len(in_list_2) < 3:
+                return u"Not Measured.", u"Not Measured."
+
+            hdr_lat_1 = u""
+            if len(in_list_1) == 4:
+                in_list_1[3] += u"=" * (len(in_list_1[3]) % 4)
+                try:
+                    hdr_lat_1 = hdrh.histogram.HdrHistogram.decode(in_list_1[3])
+                except hdrh.codec.HdrLengthException:
+                    pass
+            hdr_lat_2 = u""
+            if len(in_list_2) == 4:
+                in_list_2[3] += u"=" * (len(in_list_2[3]) % 4)
+                try:
+                    hdr_lat_2 = hdrh.histogram.HdrHistogram.decode(in_list_2[3])
+                except hdrh.codec.HdrLengthException:
+                    pass
+
+            hdr_lat = u"Not Measured."
+            if hdr_lat_1 and hdr_lat_2:
+                hdr_lat = (
+                    f"50%/90%/99%/99.9%, "
+                    f"{hdr_lat_1.get_value_at_percentile(50.0)}/"
+                    f"{hdr_lat_1.get_value_at_percentile(90.0)}/"
+                    f"{hdr_lat_1.get_value_at_percentile(99.0)}/"
+                    f"{hdr_lat_1.get_value_at_percentile(99.9)}, "
+                    f"{hdr_lat_2.get_value_at_percentile(50.0)}/"
+                    f"{hdr_lat_2.get_value_at_percentile(90.0)}/"
+                    f"{hdr_lat_2.get_value_at_percentile(99.0)}/"
+                    f"{hdr_lat_2.get_value_at_percentile(99.9)} "
+                    f"uSec."
+                )
 
-            return f"min={in_list[0]}, avg={in_list[1]}, max={in_list[2]}"
+            return (
+                f"Min/Avg/Max, "
+                f"{in_list_1[0]}/{in_list_1[1]}/{in_list_1[2]}, "
+                f"{in_list_2[0]}/{in_list_2[1]}/{in_list_2[2]} uSec.",
+                hdr_lat
+            )
 
         try:
+            pdr_lat = _process_lat(data[u'pdr_lat_1'], data[u'pdr_lat_2'])
+            ndr_lat = _process_lat(data[u'ndr_lat_1'], data[u'ndr_lat_2'])
             return (
-                f"NDR Lower: {(data[u'ndr_low'] / 1e6):.2f}"
+                f"NDR Throughput: {(data[u'ndr_low'] / 1e6):.2f} "
                 f"M{data[u'ndr_low_unit']}, "
-                f"{data[u'ndr_low_b']:.2f}{data[u'ndr_low_b_unit']}\n"
-                # f"NDR Upper: {(data[u'ndr_up'] / 1e6):.2f}"
-                # f"M{data[u'ndr_up_unit']}, "
-                # f"{data[u'ndr_up_b']:.2f}{data[u'ndr_up_b_unit']}\n"
-                f"NDR Latency W-E: {_process_lat(data[u'ndr_lat_1'])}\n"
-                f"NDR Latency E-W: {_process_lat(data[u'ndr_lat_2'])}\n"
-                f"PDR Lower: {(data[u'pdr_low'] / 1e6):.2f}"
+                f"{data[u'ndr_low_b']:.2f} {data[u'ndr_low_b_unit']}.\n"
+                f"One-Way Latency at NDR: {ndr_lat[0]}\n"
+                f"One-Way Latency at NDR by percentiles: {ndr_lat[1]}\n"
+                f"PDR Throughput: {(data[u'pdr_low'] / 1e6):.2f} "
                 f"M{data[u'pdr_low_unit']}, "
-                f"{data[u'pdr_low_b']:.2f}{data[u'pdr_low_b_unit']}\n"
-                # f"PDR Upper: {(data[u'pdr_up'] / 1e6):.2f}"
-                # f"M{data[u'pdr_up_unit']}, "
-                # f"{data[u'pdr_up_b']:.2f}{data[u'pdr_up_b_unit']}\n"
-                f"PDR Latency W-E: {_process_lat(data[u'pdr_lat_1'])}\n"
-                f"PDR Latency E-W: {_process_lat(data[u'pdr_lat_2'])}"
+                f"{data[u'pdr_low_b']:.2f} {data[u'pdr_low_b_unit']}.\n"
+                f"One-Way Latency at PDR: {pdr_lat[0]}\n"
+                f"One-Way Latency at PDR by percentiles: {pdr_lat[1]}"
             )
         except (AttributeError, IndexError, ValueError, KeyError):
             return msg
@@ -559,6 +602,12 @@ class ExecutionChecker(ResultVisitor):
         if not msg.message.count(u"stats runtime"):
             return
 
+        self._sh_run_counter += 1
+
+        # Temporary solution
+        if self._sh_run_counter > 1:
+            return
+
         if u"show-run" not in self._data[u"tests"][self._test_id].keys():
             self._data[u"tests"][self._test_id][u"show-run"] = dict()
 
@@ -882,6 +931,8 @@ class ExecutionChecker(ResultVisitor):
         :returns: Nothing.
         """
 
+        self._sh_run_counter = 0
+
         longname_orig = test.longname.lower()
 
         # Check the ignore list