1 # Copyright (c) 2020 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.
14 """Algorithms to generate plots.
24 import plotly.offline as ploff
25 import plotly.graph_objs as plgo
27 from collections import OrderedDict
28 from copy import deepcopy
31 from plotly.exceptions import PlotlyError
33 from pal_utils import mean, stdev
62 REGEX_NIC = re.compile(r'(\d*ge\dp\d\D*\d*[a-z]*)-')
65 def generate_plots(spec, data):
66 """Generate all plots specified in the specification file.
68 :param spec: Specification read from the specification file.
69 :param data: Data to process.
70 :type spec: Specification
75 u"plot_nf_reconf_box_name": plot_nf_reconf_box_name,
76 u"plot_perf_box_name": plot_perf_box_name,
77 u"plot_tsa_name": plot_tsa_name,
78 u"plot_http_server_perf_box": plot_http_server_perf_box,
79 u"plot_nf_heatmap": plot_nf_heatmap,
80 u"plot_hdrh_lat_by_percentile": plot_hdrh_lat_by_percentile
83 logging.info(u"Generating the plots ...")
84 for index, plot in enumerate(spec.plots):
86 logging.info(f" Plot nr {index + 1}: {plot.get(u'title', u'')}")
87 plot[u"limits"] = spec.configuration[u"limits"]
88 generator[plot[u"algorithm"]](plot, data)
89 logging.info(u" Done.")
90 except NameError as err:
92 f"Probably algorithm {plot[u'algorithm']} is not defined: "
95 logging.info(u"Done.")
98 def plot_hdrh_lat_by_percentile(plot, input_data):
99 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile
100 specified in the specification file.
102 :param plot: Plot to generate.
103 :param input_data: Data to process.
104 :type plot: pandas.Series
105 :type input_data: InputData
110 f" Creating the data set for the {plot.get(u'type', u'')} "
111 f"{plot.get(u'title', u'')}."
113 if plot.get(u"include", None):
114 data = input_data.filter_tests_by_name(
116 params=[u"name", u"latency", u"parent", u"tags", u"type"]
118 elif plot.get(u"filter", None):
119 data = input_data.filter_data(
121 params=[u"name", u"latency", u"parent", u"tags", u"type"],
122 continue_on_error=True
125 job = list(plot[u"data"].keys())[0]
126 build = str(plot[u"data"][job][0])
127 data = input_data.tests(job, build)
129 if data is None or len(data) == 0:
130 logging.error(u"No data.")
134 u"LAT0": u"No-load.",
135 u"PDR10": u"Low-load, 10% PDR.",
136 u"PDR50": u"Mid-load, 50% PDR.",
137 u"PDR90": u"High-load, 90% PDR.",
138 u"PDR": u"Full-load, 100% PDR.",
139 u"NDR10": u"Low-load, 10% NDR.",
140 u"NDR50": u"Mid-load, 50% NDR.",
141 u"NDR90": u"High-load, 90% NDR.",
142 u"NDR": u"Full-load, 100% NDR."
152 file_links = plot.get(u"output-file-links", None)
153 target_links = plot.get(u"target-links", None)
157 if test[u"type"] not in (u"NDRPDR",):
158 logging.warning(f"Invalid test type: {test[u'type']}")
160 name = re.sub(REGEX_NIC, u"", test[u"parent"].
161 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
163 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
164 except (IndexError, AttributeError, KeyError, ValueError):
166 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
168 logging.info(f" Generating the graph: {name_link}")
171 layout = deepcopy(plot[u"layout"])
173 for color, graph in enumerate(graphs):
174 for idx, direction in enumerate((u"direction1", u"direction2")):
178 f"<b>{desc[graph]}</b><br>"
179 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
180 f"Percentile: 0.0%<br>"
184 decoded = hdrh.histogram.HdrHistogram.decode(
185 test[u"latency"][graph][direction][u"hdrh"]
187 except hdrh.codec.HdrLengthException:
189 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
193 for item in decoded.get_recorded_iterator():
194 percentile = item.percentile_level_iterated_to
195 if percentile > 99.9:
197 xaxis.append(percentile)
198 yaxis.append(item.value_iterated_to)
200 f"<b>{desc[graph]}</b><br>"
201 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
202 f"Percentile: {percentile:.5f}%<br>"
203 f"Latency: {item.value_iterated_to}uSec"
211 legendgroup=desc[graph],
212 showlegend=bool(idx),
215 dash=u"dash" if idx % 2 else u"solid"
222 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
223 fig.update_layout(layout)
226 file_name = f"{plot[u'output-file']}-{name_link}.html"
227 logging.info(f" Writing file {file_name}")
231 ploff.plot(fig, show_link=False, auto_open=False,
233 # Add link to the file:
234 if file_links and target_links:
235 with open(file_links, u"a") as file_handler:
238 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
240 except FileNotFoundError as err:
242 f"Not possible to write the link to the file "
243 f"{file_links}\n{err}"
245 except PlotlyError as err:
246 logging.error(f" Finished with error: {repr(err)}")
248 except hdrh.codec.HdrLengthException as err:
249 logging.warning(repr(err))
252 except (ValueError, KeyError) as err:
253 logging.warning(repr(err))
257 def plot_hdrh_lat_by_percentile_x_log(plot, input_data):
258 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile_x_log
259 specified in the specification file.
261 :param plot: Plot to generate.
262 :param input_data: Data to process.
263 :type plot: pandas.Series
264 :type input_data: InputData
269 f" Creating the data set for the {plot.get(u'type', u'')} "
270 f"{plot.get(u'title', u'')}."
272 if plot.get(u"include", None):
273 data = input_data.filter_tests_by_name(
275 params=[u"name", u"latency", u"parent", u"tags", u"type"]
277 elif plot.get(u"filter", None):
278 data = input_data.filter_data(
280 params=[u"name", u"latency", u"parent", u"tags", u"type"],
281 continue_on_error=True
284 job = list(plot[u"data"].keys())[0]
285 build = str(plot[u"data"][job][0])
286 data = input_data.tests(job, build)
288 if data is None or len(data) == 0:
289 logging.error(u"No data.")
293 u"LAT0": u"No-load.",
294 u"PDR10": u"Low-load, 10% PDR.",
295 u"PDR50": u"Mid-load, 50% PDR.",
296 u"PDR90": u"High-load, 90% PDR.",
297 u"PDR": u"Full-load, 100% PDR.",
298 u"NDR10": u"Low-load, 10% NDR.",
299 u"NDR50": u"Mid-load, 50% NDR.",
300 u"NDR90": u"High-load, 90% NDR.",
301 u"NDR": u"Full-load, 100% NDR."
311 file_links = plot.get(u"output-file-links", None)
312 target_links = plot.get(u"target-links", None)
316 if test[u"type"] not in (u"NDRPDR",):
317 logging.warning(f"Invalid test type: {test[u'type']}")
319 name = re.sub(REGEX_NIC, u"", test[u"parent"].
320 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
322 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
323 except (IndexError, AttributeError, KeyError, ValueError):
325 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
327 logging.info(f" Generating the graph: {name_link}")
330 layout = deepcopy(plot[u"layout"])
333 for color, graph in enumerate(graphs):
334 for idx, direction in enumerate((u"direction1", u"direction2")):
339 decoded = hdrh.histogram.HdrHistogram.decode(
340 test[u"latency"][graph][direction][u"hdrh"]
342 except hdrh.codec.HdrLengthException:
344 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
348 for item in decoded.get_recorded_iterator():
349 percentile = item.percentile_level_iterated_to
350 if percentile > 99.9999999:
352 xaxis.append(100.0 / (100.0 - percentile))
353 yaxis.append(item.value_iterated_to)
355 f"<b>{desc[graph]}</b><br>"
356 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
357 f"Percentile: {percentile:.5f}%<br>"
358 f"Latency: {item.value_iterated_to}uSec"
366 legendgroup=desc[graph],
367 showlegend=not(bool(idx)),
370 dash=u"dash" if idx % 2 else u"solid"
376 xaxis_max = max(xaxis) if xaxis_max < max(
377 xaxis) else xaxis_max
379 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
380 layout[u"xaxis"][u"range"] = [0, int(log(xaxis_max, 10)) + 1]
381 fig.update_layout(layout)
384 file_name = f"{plot[u'output-file']}-{name_link}.html"
385 logging.info(f" Writing file {file_name}")
389 ploff.plot(fig, show_link=False, auto_open=False,
391 # Add link to the file:
392 if file_links and target_links:
393 with open(file_links, u"a") as file_handler:
396 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
398 except FileNotFoundError as err:
400 f"Not possible to write the link to the file "
401 f"{file_links}\n{err}"
403 except PlotlyError as err:
404 logging.error(f" Finished with error: {repr(err)}")
406 except hdrh.codec.HdrLengthException as err:
407 logging.warning(repr(err))
410 except (ValueError, KeyError) as err:
411 logging.warning(repr(err))
415 def plot_nf_reconf_box_name(plot, input_data):
416 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
417 specified in the specification file.
419 :param plot: Plot to generate.
420 :param input_data: Data to process.
421 :type plot: pandas.Series
422 :type input_data: InputData
427 f" Creating the data set for the {plot.get(u'type', u'')} "
428 f"{plot.get(u'title', u'')}."
430 data = input_data.filter_tests_by_name(
431 plot, params=[u"result", u"parent", u"tags", u"type"]
434 logging.error(u"No data.")
437 # Prepare the data for the plot
438 y_vals = OrderedDict()
443 if y_vals.get(test[u"parent"], None) is None:
444 y_vals[test[u"parent"]] = list()
445 loss[test[u"parent"]] = list()
447 y_vals[test[u"parent"]].append(test[u"result"][u"time"])
448 loss[test[u"parent"]].append(test[u"result"][u"loss"])
449 except (KeyError, TypeError):
450 y_vals[test[u"parent"]].append(None)
452 # Add None to the lists with missing data
454 nr_of_samples = list()
455 for val in y_vals.values():
456 if len(val) > max_len:
458 nr_of_samples.append(len(val))
459 for val in y_vals.values():
460 if len(val) < max_len:
461 val.extend([None for _ in range(max_len - len(val))])
465 df_y = pd.DataFrame(y_vals)
467 for i, col in enumerate(df_y.columns):
468 tst_name = re.sub(REGEX_NIC, u"",
469 col.lower().replace(u'-ndrpdr', u'').
470 replace(u'2n1l-', u''))
472 traces.append(plgo.Box(
473 x=[str(i + 1) + u'.'] * len(df_y[col]),
474 y=[y if y else None for y in df_y[col]],
477 f"({nr_of_samples[i]:02d} "
478 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
479 f"packets lost average: {mean(loss[col]):.1f}) "
480 f"{u'-'.join(tst_name.split(u'-')[3:-2])}"
486 layout = deepcopy(plot[u"layout"])
487 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
488 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
489 layout[u"legend"][u"font"][u"size"] = 14
490 layout[u"yaxis"].pop(u"range")
491 plpl = plgo.Figure(data=traces, layout=layout)
494 file_type = plot.get(u"output-file-type", u".html")
495 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
500 filename=f"{plot[u'output-file']}{file_type}"
502 except PlotlyError as err:
504 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
509 def plot_perf_box_name(plot, input_data):
510 """Generate the plot(s) with algorithm: plot_perf_box_name
511 specified in the specification file.
513 :param plot: Plot to generate.
514 :param input_data: Data to process.
515 :type plot: pandas.Series
516 :type input_data: InputData
521 f" Creating data set for the {plot.get(u'type', u'')} "
522 f"{plot.get(u'title', u'')}."
524 data = input_data.filter_tests_by_name(
526 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
528 logging.error(u"No data.")
531 # Prepare the data for the plot
532 plot_title = plot.get(u"title", u"").lower()
534 if u"-gbps" in plot_title:
538 value = u"throughput"
540 y_vals = OrderedDict()
543 for item in plot.get(u"include", tuple()):
544 reg_ex = re.compile(str(item).lower())
547 for test_id, test in build.iteritems():
548 if not re.match(reg_ex, str(test_id).lower()):
550 if y_vals.get(test[u"parent"], None) is None:
551 y_vals[test[u"parent"]] = list()
553 if test[u"type"] in (u"NDRPDR", u"CPS"):
554 test_type = test[u"type"]
556 if u"-pdr" in plot_title:
558 elif u"-ndr" in plot_title:
562 u"Wrong title. No information about test "
563 u"type. Add '-ndr' or '-pdr' to the test "
567 y_vals[test[u"parent"]].append(
568 test[value][ttype][u"LOWER"] * multiplier
571 elif test[u"type"] in (u"SOAK",):
572 y_vals[test[u"parent"]]. \
573 append(test[u"throughput"][u"LOWER"])
576 elif test[u"type"] in (u"HOSTSTACK",):
577 if u"LDPRELOAD" in test[u"tags"]:
578 y_vals[test[u"parent"]].append(
580 test[u"result"][u"bits_per_second"]
583 elif u"VPPECHO" in test[u"tags"]:
584 y_vals[test[u"parent"]].append(
586 test[u"result"][u"client"][u"tx_data"]
589 test[u"result"][u"client"][u"time"]
592 test[u"result"][u"server"][u"time"])
595 test_type = u"HOSTSTACK"
600 except (KeyError, TypeError):
601 y_vals[test[u"parent"]].append(None)
603 # Add None to the lists with missing data
605 nr_of_samples = list()
606 for val in y_vals.values():
607 if len(val) > max_len:
609 nr_of_samples.append(len(val))
610 for val in y_vals.values():
611 if len(val) < max_len:
612 val.extend([None for _ in range(max_len - len(val))])
616 df_y = pd.DataFrame(y_vals)
619 for i, col in enumerate(df_y.columns):
620 tst_name = re.sub(REGEX_NIC, u"",
621 col.lower().replace(u'-ndrpdr', u'').
622 replace(u'2n1l-', u''))
624 x=[str(i + 1) + u'.'] * len(df_y[col]),
625 y=[y / 1e6 if y else None for y in df_y[col]],
628 f"({nr_of_samples[i]:02d} "
629 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
634 if test_type in (u"SOAK", ):
635 kwargs[u"boxpoints"] = u"all"
637 traces.append(plgo.Box(**kwargs))
640 val_max = max(df_y[col])
642 y_max.append(int(val_max / 1e6) + 2)
643 except (ValueError, TypeError) as err:
644 logging.error(repr(err))
649 layout = deepcopy(plot[u"layout"])
650 if layout.get(u"title", None):
651 if test_type in (u"HOSTSTACK", ):
652 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
653 elif test_type in (u"CPS", ):
654 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
656 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
658 layout[u"yaxis"][u"range"] = [0, max(y_max)]
659 plpl = plgo.Figure(data=traces, layout=layout)
662 logging.info(f" Writing file {plot[u'output-file']}.html.")
667 filename=f"{plot[u'output-file']}.html"
669 except PlotlyError as err:
671 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
676 def plot_tsa_name(plot, input_data):
677 """Generate the plot(s) with algorithm:
679 specified in the specification file.
681 :param plot: Plot to generate.
682 :param input_data: Data to process.
683 :type plot: pandas.Series
684 :type input_data: InputData
688 plot_title = plot.get(u"title", u"")
690 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
692 data = input_data.filter_tests_by_name(
694 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
697 logging.error(u"No data.")
700 plot_title = plot_title.lower()
702 if u"-gbps" in plot_title:
707 value = u"throughput"
711 y_vals = OrderedDict()
712 for item in plot.get(u"include", tuple()):
713 reg_ex = re.compile(str(item).lower())
716 for test_id, test in build.iteritems():
717 if re.match(reg_ex, str(test_id).lower()):
718 if y_vals.get(test[u"parent"], None) is None:
719 y_vals[test[u"parent"]] = {
725 if test[u"type"] not in (u"NDRPDR", u"CPS"):
728 if u"-pdr" in plot_title:
730 elif u"-ndr" in plot_title:
735 if u"1C" in test[u"tags"]:
736 y_vals[test[u"parent"]][u"1"].append(
737 test[value][ttype][u"LOWER"] * multiplier
739 elif u"2C" in test[u"tags"]:
740 y_vals[test[u"parent"]][u"2"].append(
741 test[value][ttype][u"LOWER"] * multiplier
743 elif u"4C" in test[u"tags"]:
744 y_vals[test[u"parent"]][u"4"].append(
745 test[value][ttype][u"LOWER"] * multiplier
747 except (KeyError, TypeError):
751 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
755 for test_name, test_vals in y_vals.items():
756 for key, test_val in test_vals.items():
758 avg_val = sum(test_val) / len(test_val)
759 y_vals[test_name][key] = [avg_val, len(test_val)]
760 ideal = avg_val / (int(key) * 1e6)
761 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
762 y_1c_max[test_name] = ideal
769 for test_name, test_vals in y_vals.items():
771 if test_vals[u"1"][1]:
775 test_name.replace(u'-ndrpdr', u'').replace(u'2n1l-', u'')
777 vals[name] = OrderedDict()
778 y_val_1 = test_vals[u"1"][0] / 1e6
779 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
781 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
784 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
785 vals[name][u"rel"] = [1.0, None, None]
786 vals[name][u"ideal"] = [
788 y_1c_max[test_name] * 2,
789 y_1c_max[test_name] * 4
791 vals[name][u"diff"] = [
792 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None
794 vals[name][u"count"] = [
801 val_max = max(vals[name][u"val"])
802 except ValueError as err:
803 logging.error(repr(err))
806 y_max.append(val_max)
809 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
810 vals[name][u"diff"][1] = \
811 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
813 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
814 vals[name][u"diff"][2] = \
815 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
816 except IndexError as err:
817 logging.warning(f"No data for {test_name}")
818 logging.warning(repr(err))
821 if u"x520" in test_name:
822 limit = plot[u"limits"][u"nic"][u"x520"]
823 elif u"x710" in test_name:
824 limit = plot[u"limits"][u"nic"][u"x710"]
825 elif u"xxv710" in test_name:
826 limit = plot[u"limits"][u"nic"][u"xxv710"]
827 elif u"xl710" in test_name:
828 limit = plot[u"limits"][u"nic"][u"xl710"]
829 elif u"x553" in test_name:
830 limit = plot[u"limits"][u"nic"][u"x553"]
831 elif u"cx556a" in test_name:
832 limit = plot[u"limits"][u"nic"][u"cx556a"]
835 if limit > nic_limit:
838 mul = 2 if u"ge2p" in test_name else 1
839 if u"10ge" in test_name:
840 limit = plot[u"limits"][u"link"][u"10ge"] * mul
841 elif u"25ge" in test_name:
842 limit = plot[u"limits"][u"link"][u"25ge"] * mul
843 elif u"40ge" in test_name:
844 limit = plot[u"limits"][u"link"][u"40ge"] * mul
845 elif u"100ge" in test_name:
846 limit = plot[u"limits"][u"link"][u"100ge"] * mul
849 if limit > lnk_limit:
852 if u"cx556a" in test_name:
853 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
855 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
856 if limit > pci_limit:
864 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
868 min_limit = min((nic_limit, lnk_limit, pci_limit))
869 if nic_limit == min_limit:
870 traces.append(plgo.Scatter(
872 y=[nic_limit, ] * len(x_vals),
873 name=f"NIC: {nic_limit:.2f}Mpps",
882 annotations.append(dict(
889 text=f"NIC: {nic_limit:.2f}Mpps",
897 y_max.append(nic_limit)
898 elif lnk_limit == min_limit:
899 traces.append(plgo.Scatter(
901 y=[lnk_limit, ] * len(x_vals),
902 name=f"Link: {lnk_limit:.2f}Mpps",
911 annotations.append(dict(
918 text=f"Link: {lnk_limit:.2f}Mpps",
926 y_max.append(lnk_limit)
927 elif pci_limit == min_limit:
928 traces.append(plgo.Scatter(
930 y=[pci_limit, ] * len(x_vals),
931 name=f"PCIe: {pci_limit:.2f}Mpps",
940 annotations.append(dict(
947 text=f"PCIe: {pci_limit:.2f}Mpps",
955 y_max.append(pci_limit)
957 # Perfect and measured:
959 for name, val in vals.items():
962 for idx in range(len(val[u"val"])):
964 if isinstance(val[u"val"][idx], float):
966 f"No. of Runs: {val[u'count'][idx]}<br>"
967 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
969 if isinstance(val[u"diff"][idx], float):
970 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
971 if isinstance(val[u"rel"][idx], float):
972 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
973 hovertext.append(htext)
980 mode=u"lines+markers",
989 hoverinfo=u"text+name"
996 name=f"{name} perfect",
1004 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1009 except (IndexError, ValueError, KeyError) as err:
1010 logging.warning(f"No data for {name}\n{repr(err)}")
1014 file_type = plot.get(u"output-file-type", u".html")
1015 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
1016 layout = deepcopy(plot[u"layout"])
1017 if layout.get(u"title", None):
1018 layout[u"title"] = f"<b>Speedup Multi-core:</b> {layout[u'title']}"
1019 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1020 layout[u"annotations"].extend(annotations)
1021 plpl = plgo.Figure(data=traces, layout=layout)
1028 filename=f"{plot[u'output-file']}{file_type}"
1030 except PlotlyError as err:
1032 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1037 def plot_http_server_perf_box(plot, input_data):
1038 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1039 specified in the specification file.
1041 :param plot: Plot to generate.
1042 :param input_data: Data to process.
1043 :type plot: pandas.Series
1044 :type input_data: InputData
1047 # Transform the data
1049 f" Creating the data set for the {plot.get(u'type', u'')} "
1050 f"{plot.get(u'title', u'')}."
1052 data = input_data.filter_data(plot)
1054 logging.error(u"No data.")
1057 # Prepare the data for the plot
1062 if y_vals.get(test[u"name"], None) is None:
1063 y_vals[test[u"name"]] = list()
1065 y_vals[test[u"name"]].append(test[u"result"])
1066 except (KeyError, TypeError):
1067 y_vals[test[u"name"]].append(None)
1069 # Add None to the lists with missing data
1071 nr_of_samples = list()
1072 for val in y_vals.values():
1073 if len(val) > max_len:
1075 nr_of_samples.append(len(val))
1076 for val in y_vals.values():
1077 if len(val) < max_len:
1078 val.extend([None for _ in range(max_len - len(val))])
1082 df_y = pd.DataFrame(y_vals)
1084 for i, col in enumerate(df_y.columns):
1087 f"({nr_of_samples[i]:02d} " \
1088 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1089 f"{col.lower().replace(u'-ndrpdr', u'')}"
1091 name_lst = name.split(u'-')
1094 for segment in name_lst:
1095 if (len(name) + len(segment) + 1) > 50 and split_name:
1098 name += segment + u'-'
1101 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1107 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1111 f" Writing file {plot[u'output-file']}"
1112 f"{plot[u'output-file-type']}."
1118 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1120 except PlotlyError as err:
1122 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1127 def plot_nf_heatmap(plot, input_data):
1128 """Generate the plot(s) with algorithm: plot_nf_heatmap
1129 specified in the specification file.
1131 :param plot: Plot to generate.
1132 :param input_data: Data to process.
1133 :type plot: pandas.Series
1134 :type input_data: InputData
1137 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1138 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1140 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1143 # Transform the data
1145 f" Creating the data set for the {plot.get(u'type', u'')} "
1146 f"{plot.get(u'title', u'')}."
1148 data = input_data.filter_data(plot, continue_on_error=True)
1149 if data is None or data.empty:
1150 logging.error(u"No data.")
1156 for tag in test[u"tags"]:
1157 groups = re.search(regex_cn, tag)
1159 chain = str(groups.group(1))
1160 node = str(groups.group(2))
1164 groups = re.search(regex_test_name, test[u"name"])
1165 if groups and len(groups.groups()) == 3:
1167 f"{str(groups.group(1))}-"
1168 f"{str(groups.group(2))}-"
1169 f"{str(groups.group(3))}"
1173 if vals.get(chain, None) is None:
1174 vals[chain] = dict()
1175 if vals[chain].get(node, None) is None:
1176 vals[chain][node] = dict(
1184 if plot[u"include-tests"] == u"MRR":
1185 result = test[u"result"][u"receive-rate"]
1186 elif plot[u"include-tests"] == u"PDR":
1187 result = test[u"throughput"][u"PDR"][u"LOWER"]
1188 elif plot[u"include-tests"] == u"NDR":
1189 result = test[u"throughput"][u"NDR"][u"LOWER"]
1196 vals[chain][node][u"vals"].append(result)
1199 logging.error(u"No data.")
1205 txt_chains.append(key_c)
1206 for key_n in vals[key_c].keys():
1207 txt_nodes.append(key_n)
1208 if vals[key_c][key_n][u"vals"]:
1209 vals[key_c][key_n][u"nr"] = len(vals[key_c][key_n][u"vals"])
1210 vals[key_c][key_n][u"mean"] = \
1211 round(mean(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1212 vals[key_c][key_n][u"stdev"] = \
1213 round(stdev(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1214 txt_nodes = list(set(txt_nodes))
1216 def sort_by_int(value):
1217 """Makes possible to sort a list of strings which represent integers.
1219 :param value: Integer as a string.
1221 :returns: Integer representation of input parameter 'value'.
1226 txt_chains = sorted(txt_chains, key=sort_by_int)
1227 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1229 chains = [i + 1 for i in range(len(txt_chains))]
1230 nodes = [i + 1 for i in range(len(txt_nodes))]
1232 data = [list() for _ in range(len(chains))]
1233 for chain in chains:
1236 val = vals[txt_chains[chain - 1]][txt_nodes[node - 1]][u"mean"]
1237 except (KeyError, IndexError):
1239 data[chain - 1].append(val)
1242 my_green = [[0.0, u"rgb(235, 249, 242)"],
1243 [1.0, u"rgb(45, 134, 89)"]]
1245 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1246 [1.0, u"rgb(57, 115, 172)"]]
1248 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1249 [1.0, u"rgb(102, 102, 102)"]]
1252 annotations = list()
1254 text = (u"Test: {name}<br>"
1259 for chain, _ in enumerate(txt_chains):
1261 for node, _ in enumerate(txt_nodes):
1262 if data[chain][node] is not None:
1271 text=str(data[chain][node]),
1279 hover_line.append(text.format(
1280 name=vals[txt_chains[chain]][txt_nodes[node]][u"name"],
1281 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1282 val=data[chain][node],
1283 stdev=vals[txt_chains[chain]][txt_nodes[node]][u"stdev"]))
1284 hovertext.append(hover_line)
1292 title=plot.get(u"z-axis", u""),
1306 colorscale=my_green,
1312 for idx, item in enumerate(txt_nodes):
1330 for idx, item in enumerate(txt_chains):
1357 text=plot.get(u"x-axis", u""),
1374 text=plot.get(u"y-axis", u""),
1383 updatemenus = list([
1394 u"colorscale": [my_green, ],
1395 u"reversescale": False
1404 u"colorscale": [my_blue, ],
1405 u"reversescale": False
1414 u"colorscale": [my_grey, ],
1415 u"reversescale": False
1426 layout = deepcopy(plot[u"layout"])
1427 except KeyError as err:
1428 logging.error(f"Finished with error: No layout defined\n{repr(err)}")
1431 layout[u"annotations"] = annotations
1432 layout[u'updatemenus'] = updatemenus
1436 plpl = plgo.Figure(data=traces, layout=layout)
1439 logging.info(f" Writing file {plot[u'output-file']}.html")
1444 filename=f"{plot[u'output-file']}.html"
1446 except PlotlyError as err:
1448 f" Finished with error: {repr(err)}".replace(u"\n", u" ")