CSIT-1404: Add data pre-processing for "service density" graphs 60/16960/11
authorTibor Frank <tifrank@cisco.com>
Tue, 22 Jan 2019 10:24:01 +0000 (11:24 +0100)
committerTibor Frank <tifrank@cisco.com>
Tue, 22 Jan 2019 11:59:59 +0000 (12:59 +0100)
Change-Id: Icd5709cd627999bc3ecc101abffb2ace3afdb246
Signed-off-by: Tibor Frank <tifrank@cisco.com>
resources/tools/presentation/generator_plots.py
resources/tools/presentation/specification.yaml

index ca1cd9b..79ccf61 100644 (file)
@@ -15,6 +15,7 @@
 """
 
 
 """
 
 
+import re
 import logging
 import pandas as pd
 import plotly.offline as ploff
 import logging
 import pandas as pd
 import plotly.offline as ploff
@@ -24,7 +25,7 @@ from plotly.exceptions import PlotlyError
 from collections import OrderedDict
 from copy import deepcopy
 
 from collections import OrderedDict
 from copy import deepcopy
 
-from utils import mean
+from utils import mean, stdev
 
 
 COLORS = ["SkyBlue", "Olive", "Purple", "Coral", "Indigo", "Pink",
 
 
 COLORS = ["SkyBlue", "Olive", "Purple", "Coral", "Indigo", "Pink",
@@ -1095,24 +1096,85 @@ def plot_service_density_heatmap(plot, input_data):
     :type input_data: InputData
     """
 
     :type input_data: InputData
     """
 
-    # Example data in Mpps
-    txt_chains = ['1', '2', '4', '6', '8', '10']
-    txt_nodes = ['1', '2', '4', '6', '8', '10']
+    REGEX_CN = re.compile(r'^(\d*)C(\d*)N$')
+    
+    txt_chains = list()
+    txt_nodes = list()
+    vals = dict()
+
+    # Transform the data
+    logging.info("    Creating the data set for the {0} '{1}'.".
+                 format(plot.get("type", ""), plot.get("title", "")))
+    data = input_data.filter_data(plot, continue_on_error=True)
+    if data is None:
+        logging.error("No data.")
+        return
+    
+    for job in data:
+        for build in job:
+            for test in build:
+                for tag in test['tags']:
+                    groups = re.search(REGEX_CN, tag)
+                    if groups:
+                        c = str(groups.group(1))
+                        n = str(groups.group(2))
+                        break
+                else:
+                    continue
+                if vals.get(c, None) is None:
+                    vals[c] = dict()
+                if vals[c].get(n, None) is None:
+                    vals[c][n] = dict(name=test["name"],
+                                      vals=list(),
+                                      nr=None,
+                                      mean=None,
+                                      stdev=None)
+                if plot["include-tests"] == "MRR":
+                    result = test["result"]["receive-rate"].avg
+                elif plot["include-tests"] == "PDR":
+                    result = test["throughput"]["PDR"]["LOWER"]
+                elif plot["include-tests"] == "NDR":
+                    result = test["throughput"]["NDR"]["LOWER"]
+                else:
+                    result = None
+
+                if result:
+                    vals[c][n]["vals"].append(result)
+
+    for key_c in vals.keys():
+        txt_chains.append(key_c)
+        for key_n in vals[key_c].keys():
+            txt_nodes.append(key_n)
+            if vals[key_c][key_n]["vals"]:
+                vals[key_c][key_n]["nr"] = len(vals[key_c][key_n]["vals"])
+                vals[key_c][key_n]["mean"] = \
+                    round(mean(vals[key_c][key_n]["vals"]) / 1000000, 2)
+                vals[key_c][key_n]["stdev"] = \
+                    round(stdev(vals[key_c][key_n]["vals"]) / 1000000, 2)
+    txt_nodes = list(set(txt_nodes))
+
+    txt_chains = sorted(txt_chains, key=lambda chain: int(chain))
+    txt_nodes = sorted(txt_nodes, key=lambda node: int(node))
+
     chains = [i + 1 for i in range(len(txt_chains))]
     nodes = [i + 1 for i in range(len(txt_nodes))]
     chains = [i + 1 for i in range(len(txt_chains))]
     nodes = [i + 1 for i in range(len(txt_nodes))]
-    data = [
-        [6.3, 6.3, 6.3, 6.4, 6.5, 6.4],
-        [5.8, 5.6, 5.6, 5.6, 5.5, None],
-        [5.6, 5.5, 5.3, None, None, None],
-        [5.4, 5.3, None, None, None, None],
-        [5.4, 5.2, None, None, None, None],
-        [5.3, None, None, None, None, None]
-    ]
+
+    data = [list() for _ in range(len(chains))]
+    for c in chains:
+        for n in nodes:
+            try:
+                val = vals[txt_chains[c - 1]][txt_nodes[n - 1]]["mean"]
+            except (KeyError, IndexError):
+                val = None
+            data[c - 1].append(val)
 
     hovertext = list()
     annotations = list()
 
 
     hovertext = list()
     annotations = list()
 
-    text = "{name}"
+    text = ("{name}<br>"
+            "No. of Samples: {nr}<br>"
+            "Throughput: {val}<br>"
+            "Stdev: {stdev}")
 
     for c in range(len(txt_chains)):
         hover_line = list()
 
     for c in range(len(txt_chains)):
         hover_line = list()
@@ -1132,7 +1194,11 @@ def plot_service_density_heatmap(plot, input_data):
                     align="center",
                     showarrow=False
                 ))
                     align="center",
                     showarrow=False
                 ))
-                hover_line.append(text.format(name="Testcase Name"))
+                hover_line.append(text.format(
+                    name=vals[txt_chains[c]][txt_nodes[n]]["name"],
+                    nr=vals[txt_chains[c]][txt_nodes[n]]["nr"],
+                    val=data[c][n],
+                    stdev=vals[txt_chains[c]][txt_nodes[n]]["stdev"]))
         hovertext.append(hover_line)
 
     traces = [
         hovertext.append(hover_line)
 
     traces = [
index 8dc4df7..3b76065 100644 (file)
 
   data-sets:
 
 
   data-sets:
 
-    # Example
-    plot-vpp-service-density-3n-hsw:
-      csit-vpp-perf-verify-1810-3n-hsw:
-      - 28
-
     # Denverton:
     intel-dnv-vpp:
       intel-dnv-vpp-release-1810:
     # Denverton:
     intel-dnv-vpp:
       intel-dnv-vpp-release-1810:
       csit-vpp-perf-verify-master-2n-skx:
       - 207  # SOAK sel
 
       csit-vpp-perf-verify-master-2n-skx:
       - 207  # SOAK sel
 
+    plot-vpp-service-density-2n-skx:
+      csit-vpp-perf-verify-master-2n-skx:
+      - 215
+      - 216
+      - 219
+      - 221
+      - 222
     plot-vpp-throughput-latency-3n-skx:
       csit-vpp-perf-verify-1810-3n-skx:
       - 24  # NDRPDR full
     plot-vpp-throughput-latency-3n-skx:
       csit-vpp-perf-verify-1810-3n-skx:
       - 24  # NDRPDR full
     - 27  # NDRPDR sel
     csit-vpp-perf-verify-master-2n-skx:
     - 207  # SOAK sel
     - 27  # NDRPDR sel
     csit-vpp-perf-verify-master-2n-skx:
     - 207  # SOAK sel
+    - 215  # SD
+    - 216  # SD
+    - 219  # SD
+    - 221  # SD
+    - 222  # SD
     csit-vpp-perf-check-1804:
     - 5   # mrr - full
     - 6   # mrr - sel
     csit-vpp-perf-check-1804:
     - 5   # mrr - full
     - 6   # mrr - sel
 # Heatmap - example
 -
   type: "plot"
 # Heatmap - example
 -
   type: "plot"
-  title: "Service Density: l2sw-3n-hsw-x520-64b-1t1c-base_and_scale-ndr"
+  title: "Service Density: l2sw-2n-skx-x710-64b-2t1c-base-sd-mrr"
   algorithm: "plot_service_density_heatmap"
   output-file-type: ".html"
   algorithm: "plot_service_density_heatmap"
   output-file-type: ".html"
-  output-file: "{DIR[STATIC,VPP]}/l2sw-3n-hsw-x520-64b-1t1c-base_and_scale-sd-ndr"
-  data: "plot-vpp-service-density-3n-hsw"
-  filter: "'NIC_Intel-X520-DA2' and
+  output-file: "{DIR[STATIC,VPP]}/l2sw-2n-skx-x710-64b-2t1c-base-sd-mrr"
+  data: "plot-vpp-service-density-2n-skx"
+  filter: "'NIC_Intel-X710' and
+           'SERVICE_DENSITY' and
            '64B' and
            '64B' and
-           ('BASE' or 'SCALE') and
-           'NDRPDR' and
-           'ETH' and
-           '1T1C' and
-           ('L2BDMACSTAT' or 'L2BDMACLRN' or 'L2XCFWD' or 'L2PATCH') and
-           not 'VHOST' and
-           not 'MEMIF'"
+           '2T1C' and
+           'MRR'"
   parameters:
   parameters:
-  - "throughput"
+  - "result"
+  - "name"
   - "parent"
   - "tags"
   - "parent"
   - "tags"
+  include-tests: "MRR" # "PDR" | "NDR" | "MRR"
   layout:
     title: "<b>Network Service Density Matrix: Packet Throughput View</b>"
     layout: "plot-service-density"
   layout:
     title: "<b>Network Service Density Matrix: Packet Throughput View</b>"
     layout: "plot-service-density"