1 # Copyright (c) 2022 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
18 import plotly.graph_objects as go
21 from copy import deepcopy
23 from ..utils.constants import Constants as C
24 from ..utils.utils import get_color
27 def get_short_version(version: str, dut_type: str="vpp") -> str:
31 if dut_type in ("trex", "dpdk"):
36 pattern=re.compile(r"^(\d{2}).(\d{2})-(rc0|rc1|rc2|release$)"),
42 f"{groups.group(1)}.{groups.group(2)}.{groups.group(3)}".\
43 replace("release", "rls")
50 def select_iterative_data(data: pd.DataFrame, itm:dict) -> pd.DataFrame:
54 phy = itm["phy"].split("-")
56 topo, arch, nic, drv = phy
61 drv = drv.replace("_", "-")
65 core = str() if itm["dut"] == "trex" else f"{itm['core']}"
66 ttype = "ndrpdr" if itm["testtype"] in ("ndr", "pdr") else itm["testtype"]
67 dut_v100 = "none" if itm["dut"] == "trex" else itm["dut"]
71 (data["release"] == itm["rls"]) &
74 (data["version"] == "1.0.0") &
75 (data["dut_type"].str.lower() == dut_v100)
78 (data["version"] == "1.0.1") &
79 (data["dut_type"].str.lower() == dut_v101)
82 (data["test_type"] == ttype) &
83 (data["passed"] == True)
86 f"^.*[.|-]{nic}.*{itm['framesize']}-{core}-{drv}{itm['test']}-{ttype}$"
88 (df.job.str.endswith(f"{topo}-{arch}")) &
89 (df.dut_version.str.contains(itm["dutver"].replace(".r", "-r").\
90 replace("rls", "release"))) &
91 (df.test_id.str.contains(regex_test, regex=True))
97 def graph_iterative(data: pd.DataFrame, sel:dict, layout: dict,
98 normalize: bool) -> tuple:
112 for idx, itm in enumerate(sel):
113 itm_data = select_iterative_data(data, itm)
116 phy = itm["phy"].split("-")
117 topo_arch = f"{phy[0]}-{phy[1]}" if len(phy) == 4 else str()
118 norm_factor = (C.NORM_FREQUENCY / C.FREQUENCY[topo_arch]) \
119 if normalize else 1.0
120 if itm["testtype"] == "mrr":
121 y_data_raw = itm_data[C.VALUE_ITER[itm["testtype"]]].to_list()[0]
122 y_data = [(y * norm_factor) for y in y_data_raw]
125 max(y_data) if max(y_data) > y_tput_max else y_tput_max
127 y_data_raw = itm_data[C.VALUE_ITER[itm["testtype"]]].to_list()
128 y_data = [(y * norm_factor) for y in y_data_raw]
131 max(y_data) if max(y_data) > y_tput_max else y_tput_max
132 nr_of_samples = len(y_data)
137 f"({nr_of_samples:02d} "
138 f"run{'s' if nr_of_samples > 1 else ''}) "
144 marker=dict(color=get_color(idx))
146 tput_traces.append(go.Box(**tput_kwargs))
149 if itm["testtype"] == "pdr":
150 y_lat_row = itm_data[C.VALUE_ITER["pdr-lat"]].to_list()
151 y_lat = [(y / norm_factor) for y in y_lat_row]
153 y_lat_max = max(y_lat) if max(y_lat) > y_lat_max else y_lat_max
154 nr_of_samples = len(y_lat)
159 f"({nr_of_samples:02d} "
160 f"run{u's' if nr_of_samples > 1 else u''}) "
166 marker=dict(color=get_color(idx))
168 x_lat.append(idx + 1)
169 lat_traces.append(go.Box(**lat_kwargs))
172 lat_traces.append(go.Box())
175 pl_tput = deepcopy(layout["plot-throughput"])
176 pl_tput["xaxis"]["tickvals"] = [i for i in range(len(sel))]
177 pl_tput["xaxis"]["ticktext"] = [str(i + 1) for i in range(len(sel))]
179 pl_tput["yaxis"]["range"] = [0, (int(y_tput_max / 1e6) + 1) * 1e6]
180 fig_tput = go.Figure(data=tput_traces, layout=pl_tput)
183 pl_lat = deepcopy(layout["plot-latency"])
184 pl_lat["xaxis"]["tickvals"] = [i for i in range(len(x_lat))]
185 pl_lat["xaxis"]["ticktext"] = x_lat
187 pl_lat["yaxis"]["range"] = [0, (int(y_lat_max / 10) + 1) * 10]
188 fig_lat = go.Figure(data=lat_traces, layout=pl_lat)
190 return fig_tput, fig_lat
193 def table_comparison(data: pd.DataFrame, sel:dict,
194 normalize: bool) -> pd.DataFrame:
197 table = pd.DataFrame(
200 "64b-2t1c-avf-eth-l2xcbase-eth-2memif-1dcr",
201 "64b-2t1c-avf-eth-l2xcbase-eth-2vhostvr1024-1vm-vppl2xc",
202 "64b-2t1c-avf-ethip4udp-ip4base-iacl50sl-10kflows",
203 "78b-2t1c-avf-ethip6-ip6scale2m-rnd "],
224 "2110.0-9 vs 2110.0-8": [
229 "2202.0-9 vs 2110.0-9": [
237 return pd.DataFrame() #table