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,
81 u"plot_hdrh_lat_by_percentile_x_log": plot_hdrh_lat_by_percentile_x_log
84 logging.info(u"Generating the plots ...")
85 for index, plot in enumerate(spec.plots):
87 logging.info(f" Plot nr {index + 1}: {plot.get(u'title', u'')}")
88 plot[u"limits"] = spec.configuration[u"limits"]
89 generator[plot[u"algorithm"]](plot, data)
90 logging.info(u" Done.")
91 except NameError as err:
93 f"Probably algorithm {plot[u'algorithm']} is not defined: "
96 logging.info(u"Done.")
99 def plot_hdrh_lat_by_percentile(plot, input_data):
100 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile
101 specified in the specification file.
103 :param plot: Plot to generate.
104 :param input_data: Data to process.
105 :type plot: pandas.Series
106 :type input_data: InputData
111 f" Creating the data set for the {plot.get(u'type', u'')} "
112 f"{plot.get(u'title', u'')}."
114 if plot.get(u"include", None):
115 data = input_data.filter_tests_by_name(
117 params=[u"name", u"latency", u"parent", u"tags", u"type"]
119 elif plot.get(u"filter", None):
120 data = input_data.filter_data(
122 params=[u"name", u"latency", u"parent", u"tags", u"type"],
123 continue_on_error=True
126 job = list(plot[u"data"].keys())[0]
127 build = str(plot[u"data"][job][0])
128 data = input_data.tests(job, build)
130 if data is None or len(data) == 0:
131 logging.error(u"No data.")
135 u"LAT0": u"No-load.",
136 u"PDR10": u"Low-load, 10% PDR.",
137 u"PDR50": u"Mid-load, 50% PDR.",
138 u"PDR90": u"High-load, 90% PDR.",
139 u"PDR": u"Full-load, 100% PDR.",
140 u"NDR10": u"Low-load, 10% NDR.",
141 u"NDR50": u"Mid-load, 50% NDR.",
142 u"NDR90": u"High-load, 90% NDR.",
143 u"NDR": u"Full-load, 100% NDR."
153 file_links = plot.get(u"output-file-links", None)
154 target_links = plot.get(u"target-links", None)
158 if test[u"type"] not in (u"NDRPDR",):
159 logging.warning(f"Invalid test type: {test[u'type']}")
161 name = re.sub(REGEX_NIC, u"", test[u"parent"].
162 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
164 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
165 except (IndexError, AttributeError, KeyError, ValueError):
167 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
169 logging.info(f" Generating the graph: {name_link}")
172 layout = deepcopy(plot[u"layout"])
174 for color, graph in enumerate(graphs):
175 for idx, direction in enumerate((u"direction1", u"direction2")):
180 decoded = hdrh.histogram.HdrHistogram.decode(
181 test[u"latency"][graph][direction][u"hdrh"]
183 except hdrh.codec.HdrLengthException:
185 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
189 for item in decoded.get_recorded_iterator():
190 percentile = item.percentile_level_iterated_to
191 if percentile > 99.9999999:
193 xaxis.append(percentile)
194 yaxis.append(item.value_iterated_to)
196 f"<b>{desc[graph]}</b><br>"
197 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
198 f"Percentile: {percentile:.5f}%<br>"
199 f"Latency: {item.value_iterated_to}uSec"
207 legendgroup=desc[graph],
208 showlegend=bool(idx),
211 dash=u"dash" if idx % 2 else u"solid"
218 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
219 fig.update_layout(layout)
222 file_name = f"{plot[u'output-file']}-{name_link}.html"
223 logging.info(f" Writing file {file_name}")
227 ploff.plot(fig, show_link=False, auto_open=False,
229 # Add link to the file:
230 if file_links and target_links:
231 with open(file_links, u"a") as file_handler:
234 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
236 except FileNotFoundError as err:
238 f"Not possible to write the link to the file "
239 f"{file_links}\n{err}"
241 except PlotlyError as err:
242 logging.error(f" Finished with error: {repr(err)}")
244 except hdrh.codec.HdrLengthException as err:
245 logging.warning(repr(err))
248 except (ValueError, KeyError) as err:
249 logging.warning(repr(err))
253 def plot_hdrh_lat_by_percentile_x_log(plot, input_data):
254 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile_x_log
255 specified in the specification file.
257 :param plot: Plot to generate.
258 :param input_data: Data to process.
259 :type plot: pandas.Series
260 :type input_data: InputData
265 f" Creating the data set for the {plot.get(u'type', u'')} "
266 f"{plot.get(u'title', u'')}."
268 if plot.get(u"include", None):
269 data = input_data.filter_tests_by_name(
271 params=[u"name", u"latency", u"parent", u"tags", u"type"]
273 elif plot.get(u"filter", None):
274 data = input_data.filter_data(
276 params=[u"name", u"latency", u"parent", u"tags", u"type"],
277 continue_on_error=True
280 job = list(plot[u"data"].keys())[0]
281 build = str(plot[u"data"][job][0])
282 data = input_data.tests(job, build)
284 if data is None or len(data) == 0:
285 logging.error(u"No data.")
289 u"LAT0": u"No-load.",
290 u"PDR10": u"Low-load, 10% PDR.",
291 u"PDR50": u"Mid-load, 50% PDR.",
292 u"PDR90": u"High-load, 90% PDR.",
293 u"PDR": u"Full-load, 100% PDR.",
294 u"NDR10": u"Low-load, 10% NDR.",
295 u"NDR50": u"Mid-load, 50% NDR.",
296 u"NDR90": u"High-load, 90% NDR.",
297 u"NDR": u"Full-load, 100% NDR."
307 file_links = plot.get(u"output-file-links", None)
308 target_links = plot.get(u"target-links", None)
312 if test[u"type"] not in (u"NDRPDR",):
313 logging.warning(f"Invalid test type: {test[u'type']}")
315 name = re.sub(REGEX_NIC, u"", test[u"parent"].
316 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
318 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
319 except (IndexError, AttributeError, KeyError, ValueError):
321 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
323 logging.info(f" Generating the graph: {name_link}")
326 layout = deepcopy(plot[u"layout"])
329 for color, graph in enumerate(graphs):
330 for idx, direction in enumerate((u"direction1", u"direction2")):
335 decoded = hdrh.histogram.HdrHistogram.decode(
336 test[u"latency"][graph][direction][u"hdrh"]
338 except hdrh.codec.HdrLengthException:
340 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
344 for item in decoded.get_recorded_iterator():
345 percentile = item.percentile_level_iterated_to
346 if percentile > 99.9999999:
348 xaxis.append(100.0 / (100.0 - percentile))
349 yaxis.append(item.value_iterated_to)
351 f"<b>{desc[graph]}</b><br>"
352 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
353 f"Percentile: {percentile:.5f}%<br>"
354 f"Latency: {item.value_iterated_to}uSec"
362 legendgroup=desc[graph],
363 showlegend=not(bool(idx)),
366 dash=u"dash" if idx % 2 else u"solid"
372 xaxis_max = max(xaxis) if xaxis_max < max(
373 xaxis) else xaxis_max
375 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
376 layout[u"xaxis"][u"range"] = [0, int(log(xaxis_max, 10)) + 1]
377 fig.update_layout(layout)
380 file_name = f"{plot[u'output-file']}-{name_link}.html"
381 logging.info(f" Writing file {file_name}")
385 ploff.plot(fig, show_link=False, auto_open=False,
387 # Add link to the file:
388 if file_links and target_links:
389 with open(file_links, u"a") as file_handler:
392 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
394 except FileNotFoundError as err:
396 f"Not possible to write the link to the file "
397 f"{file_links}\n{err}"
399 except PlotlyError as err:
400 logging.error(f" Finished with error: {repr(err)}")
402 except hdrh.codec.HdrLengthException as err:
403 logging.warning(repr(err))
406 except (ValueError, KeyError) as err:
407 logging.warning(repr(err))
411 def plot_nf_reconf_box_name(plot, input_data):
412 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
413 specified in the specification file.
415 :param plot: Plot to generate.
416 :param input_data: Data to process.
417 :type plot: pandas.Series
418 :type input_data: InputData
423 f" Creating the data set for the {plot.get(u'type', u'')} "
424 f"{plot.get(u'title', u'')}."
426 data = input_data.filter_tests_by_name(
427 plot, params=[u"result", u"parent", u"tags", u"type"]
430 logging.error(u"No data.")
433 # Prepare the data for the plot
434 y_vals = OrderedDict()
439 if y_vals.get(test[u"parent"], None) is None:
440 y_vals[test[u"parent"]] = list()
441 loss[test[u"parent"]] = list()
443 y_vals[test[u"parent"]].append(test[u"result"][u"time"])
444 loss[test[u"parent"]].append(test[u"result"][u"loss"])
445 except (KeyError, TypeError):
446 y_vals[test[u"parent"]].append(None)
448 # Add None to the lists with missing data
450 nr_of_samples = list()
451 for val in y_vals.values():
452 if len(val) > max_len:
454 nr_of_samples.append(len(val))
455 for val in y_vals.values():
456 if len(val) < max_len:
457 val.extend([None for _ in range(max_len - len(val))])
461 df_y = pd.DataFrame(y_vals)
463 for i, col in enumerate(df_y.columns):
464 tst_name = re.sub(REGEX_NIC, u"",
465 col.lower().replace(u'-ndrpdr', u'').
466 replace(u'2n1l-', u''))
468 traces.append(plgo.Box(
469 x=[str(i + 1) + u'.'] * len(df_y[col]),
470 y=[y if y else None for y in df_y[col]],
473 f"({nr_of_samples[i]:02d} "
474 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
475 f"packets lost average: {mean(loss[col]):.1f}) "
476 f"{u'-'.join(tst_name.split(u'-')[3:-2])}"
482 layout = deepcopy(plot[u"layout"])
483 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
484 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
485 layout[u"legend"][u"font"][u"size"] = 14
486 layout[u"yaxis"].pop(u"range")
487 plpl = plgo.Figure(data=traces, layout=layout)
490 file_type = plot.get(u"output-file-type", u".html")
491 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
496 filename=f"{plot[u'output-file']}{file_type}"
498 except PlotlyError as err:
500 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
505 def plot_perf_box_name(plot, input_data):
506 """Generate the plot(s) with algorithm: plot_perf_box_name
507 specified in the specification file.
509 :param plot: Plot to generate.
510 :param input_data: Data to process.
511 :type plot: pandas.Series
512 :type input_data: InputData
517 f" Creating data set for the {plot.get(u'type', u'')} "
518 f"{plot.get(u'title', u'')}."
520 data = input_data.filter_tests_by_name(
522 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
524 logging.error(u"No data.")
527 # Prepare the data for the plot
528 plot_title = plot.get(u"title", u"").lower()
530 if u"-gbps" in plot_title:
534 value = u"throughput"
536 y_vals = OrderedDict()
539 for item in plot.get(u"include", tuple()):
540 reg_ex = re.compile(str(item).lower())
543 for test_id, test in build.iteritems():
544 if not re.match(reg_ex, str(test_id).lower()):
546 if y_vals.get(test[u"parent"], None) is None:
547 y_vals[test[u"parent"]] = list()
549 if test[u"type"] in (u"NDRPDR", u"CPS"):
550 test_type = test[u"type"]
552 if u"-pdr" in plot_title:
554 elif u"-ndr" in plot_title:
558 u"Wrong title. No information about test "
559 u"type. Add '-ndr' or '-pdr' to the test "
563 y_vals[test[u"parent"]].append(
564 test[value][ttype][u"LOWER"] * multiplier
567 elif test[u"type"] in (u"SOAK",):
568 y_vals[test[u"parent"]]. \
569 append(test[u"throughput"][u"LOWER"])
572 elif test[u"type"] in (u"HOSTSTACK",):
573 if u"LDPRELOAD" in test[u"tags"]:
574 y_vals[test[u"parent"]].append(
576 test[u"result"][u"bits_per_second"]
579 elif u"VPPECHO" in test[u"tags"]:
580 y_vals[test[u"parent"]].append(
582 test[u"result"][u"client"][u"tx_data"]
585 test[u"result"][u"client"][u"time"]
588 test[u"result"][u"server"][u"time"])
591 test_type = u"HOSTSTACK"
596 except (KeyError, TypeError):
597 y_vals[test[u"parent"]].append(None)
599 # Add None to the lists with missing data
601 nr_of_samples = list()
602 for val in y_vals.values():
603 if len(val) > max_len:
605 nr_of_samples.append(len(val))
606 for val in y_vals.values():
607 if len(val) < max_len:
608 val.extend([None for _ in range(max_len - len(val))])
612 df_y = pd.DataFrame(y_vals)
615 for i, col in enumerate(df_y.columns):
616 tst_name = re.sub(REGEX_NIC, u"",
617 col.lower().replace(u'-ndrpdr', u'').
618 replace(u'2n1l-', u''))
620 x=[str(i + 1) + u'.'] * len(df_y[col]),
621 y=[y / 1e6 if y else None for y in df_y[col]],
624 f"({nr_of_samples[i]:02d} "
625 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
630 if test_type in (u"SOAK", ):
631 kwargs[u"boxpoints"] = u"all"
633 traces.append(plgo.Box(**kwargs))
636 val_max = max(df_y[col])
638 y_max.append(int(val_max / 1e6) + 2)
639 except (ValueError, TypeError) as err:
640 logging.error(repr(err))
645 layout = deepcopy(plot[u"layout"])
646 if layout.get(u"title", None):
647 if test_type in (u"HOSTSTACK", ):
648 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
649 elif test_type in (u"CPS", ):
650 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
652 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
654 layout[u"yaxis"][u"range"] = [0, max(y_max)]
655 plpl = plgo.Figure(data=traces, layout=layout)
658 logging.info(f" Writing file {plot[u'output-file']}.html.")
663 filename=f"{plot[u'output-file']}.html"
665 except PlotlyError as err:
667 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
672 def plot_tsa_name(plot, input_data):
673 """Generate the plot(s) with algorithm:
675 specified in the specification file.
677 :param plot: Plot to generate.
678 :param input_data: Data to process.
679 :type plot: pandas.Series
680 :type input_data: InputData
684 plot_title = plot.get(u"title", u"")
686 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
688 data = input_data.filter_tests_by_name(
690 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
693 logging.error(u"No data.")
696 plot_title = plot_title.lower()
698 if u"-gbps" in plot_title:
703 value = u"throughput"
707 y_vals = OrderedDict()
708 for item in plot.get(u"include", tuple()):
709 reg_ex = re.compile(str(item).lower())
712 for test_id, test in build.iteritems():
713 if re.match(reg_ex, str(test_id).lower()):
714 if y_vals.get(test[u"parent"], None) is None:
715 y_vals[test[u"parent"]] = {
721 if test[u"type"] not in (u"NDRPDR", u"CPS"):
724 if u"-pdr" in plot_title:
726 elif u"-ndr" in plot_title:
731 if u"1C" in test[u"tags"]:
732 y_vals[test[u"parent"]][u"1"].append(
733 test[value][ttype][u"LOWER"] * multiplier
735 elif u"2C" in test[u"tags"]:
736 y_vals[test[u"parent"]][u"2"].append(
737 test[value][ttype][u"LOWER"] * multiplier
739 elif u"4C" in test[u"tags"]:
740 y_vals[test[u"parent"]][u"4"].append(
741 test[value][ttype][u"LOWER"] * multiplier
743 except (KeyError, TypeError):
747 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
751 for test_name, test_vals in y_vals.items():
752 for key, test_val in test_vals.items():
754 avg_val = sum(test_val) / len(test_val)
755 y_vals[test_name][key] = [avg_val, len(test_val)]
756 ideal = avg_val / (int(key) * 1e6)
757 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
758 y_1c_max[test_name] = ideal
765 for test_name, test_vals in y_vals.items():
767 if test_vals[u"1"][1]:
771 test_name.replace(u'-ndrpdr', u'').replace(u'2n1l-', u'')
773 vals[name] = OrderedDict()
774 y_val_1 = test_vals[u"1"][0] / 1e6
775 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
777 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
780 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
781 vals[name][u"rel"] = [1.0, None, None]
782 vals[name][u"ideal"] = [
784 y_1c_max[test_name] * 2,
785 y_1c_max[test_name] * 4
787 vals[name][u"diff"] = [
788 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None
790 vals[name][u"count"] = [
797 val_max = max(vals[name][u"val"])
798 except ValueError as err:
799 logging.error(repr(err))
802 y_max.append(val_max)
805 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
806 vals[name][u"diff"][1] = \
807 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
809 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
810 vals[name][u"diff"][2] = \
811 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
812 except IndexError as err:
813 logging.warning(f"No data for {test_name}")
814 logging.warning(repr(err))
817 if u"x520" in test_name:
818 limit = plot[u"limits"][u"nic"][u"x520"]
819 elif u"x710" in test_name:
820 limit = plot[u"limits"][u"nic"][u"x710"]
821 elif u"xxv710" in test_name:
822 limit = plot[u"limits"][u"nic"][u"xxv710"]
823 elif u"xl710" in test_name:
824 limit = plot[u"limits"][u"nic"][u"xl710"]
825 elif u"x553" in test_name:
826 limit = plot[u"limits"][u"nic"][u"x553"]
827 elif u"cx556a" in test_name:
828 limit = plot[u"limits"][u"nic"][u"cx556a"]
831 if limit > nic_limit:
834 mul = 2 if u"ge2p" in test_name else 1
835 if u"10ge" in test_name:
836 limit = plot[u"limits"][u"link"][u"10ge"] * mul
837 elif u"25ge" in test_name:
838 limit = plot[u"limits"][u"link"][u"25ge"] * mul
839 elif u"40ge" in test_name:
840 limit = plot[u"limits"][u"link"][u"40ge"] * mul
841 elif u"100ge" in test_name:
842 limit = plot[u"limits"][u"link"][u"100ge"] * mul
845 if limit > lnk_limit:
848 if u"cx556a" in test_name:
849 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
851 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
852 if limit > pci_limit:
860 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
864 min_limit = min((nic_limit, lnk_limit, pci_limit))
865 if nic_limit == min_limit:
866 traces.append(plgo.Scatter(
868 y=[nic_limit, ] * len(x_vals),
869 name=f"NIC: {nic_limit:.2f}Mpps",
878 annotations.append(dict(
885 text=f"NIC: {nic_limit:.2f}Mpps",
893 y_max.append(nic_limit)
894 elif lnk_limit == min_limit:
895 traces.append(plgo.Scatter(
897 y=[lnk_limit, ] * len(x_vals),
898 name=f"Link: {lnk_limit:.2f}Mpps",
907 annotations.append(dict(
914 text=f"Link: {lnk_limit:.2f}Mpps",
922 y_max.append(lnk_limit)
923 elif pci_limit == min_limit:
924 traces.append(plgo.Scatter(
926 y=[pci_limit, ] * len(x_vals),
927 name=f"PCIe: {pci_limit:.2f}Mpps",
936 annotations.append(dict(
943 text=f"PCIe: {pci_limit:.2f}Mpps",
951 y_max.append(pci_limit)
953 # Perfect and measured:
955 for name, val in vals.items():
958 for idx in range(len(val[u"val"])):
960 if isinstance(val[u"val"][idx], float):
962 f"No. of Runs: {val[u'count'][idx]}<br>"
963 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
965 if isinstance(val[u"diff"][idx], float):
966 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
967 if isinstance(val[u"rel"][idx], float):
968 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
969 hovertext.append(htext)
976 mode=u"lines+markers",
985 hoverinfo=u"text+name"
992 name=f"{name} perfect",
1000 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1005 except (IndexError, ValueError, KeyError) as err:
1006 logging.warning(f"No data for {name}\n{repr(err)}")
1010 file_type = plot.get(u"output-file-type", u".html")
1011 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
1012 layout = deepcopy(plot[u"layout"])
1013 if layout.get(u"title", None):
1014 layout[u"title"] = f"<b>Speedup Multi-core:</b> {layout[u'title']}"
1015 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1016 layout[u"annotations"].extend(annotations)
1017 plpl = plgo.Figure(data=traces, layout=layout)
1024 filename=f"{plot[u'output-file']}{file_type}"
1026 except PlotlyError as err:
1028 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1033 def plot_http_server_perf_box(plot, input_data):
1034 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1035 specified in the specification file.
1037 :param plot: Plot to generate.
1038 :param input_data: Data to process.
1039 :type plot: pandas.Series
1040 :type input_data: InputData
1043 # Transform the data
1045 f" Creating the data set for the {plot.get(u'type', u'')} "
1046 f"{plot.get(u'title', u'')}."
1048 data = input_data.filter_data(plot)
1050 logging.error(u"No data.")
1053 # Prepare the data for the plot
1058 if y_vals.get(test[u"name"], None) is None:
1059 y_vals[test[u"name"]] = list()
1061 y_vals[test[u"name"]].append(test[u"result"])
1062 except (KeyError, TypeError):
1063 y_vals[test[u"name"]].append(None)
1065 # Add None to the lists with missing data
1067 nr_of_samples = list()
1068 for val in y_vals.values():
1069 if len(val) > max_len:
1071 nr_of_samples.append(len(val))
1072 for val in y_vals.values():
1073 if len(val) < max_len:
1074 val.extend([None for _ in range(max_len - len(val))])
1078 df_y = pd.DataFrame(y_vals)
1080 for i, col in enumerate(df_y.columns):
1083 f"({nr_of_samples[i]:02d} " \
1084 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1085 f"{col.lower().replace(u'-ndrpdr', u'')}"
1087 name_lst = name.split(u'-')
1090 for segment in name_lst:
1091 if (len(name) + len(segment) + 1) > 50 and split_name:
1094 name += segment + u'-'
1097 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1103 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1107 f" Writing file {plot[u'output-file']}"
1108 f"{plot[u'output-file-type']}."
1114 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1116 except PlotlyError as err:
1118 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1123 def plot_nf_heatmap(plot, input_data):
1124 """Generate the plot(s) with algorithm: plot_nf_heatmap
1125 specified in the specification file.
1127 :param plot: Plot to generate.
1128 :param input_data: Data to process.
1129 :type plot: pandas.Series
1130 :type input_data: InputData
1133 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1134 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1136 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1139 # Transform the data
1141 f" Creating the data set for the {plot.get(u'type', u'')} "
1142 f"{plot.get(u'title', u'')}."
1144 data = input_data.filter_data(plot, continue_on_error=True)
1145 if data is None or data.empty:
1146 logging.error(u"No data.")
1152 for tag in test[u"tags"]:
1153 groups = re.search(regex_cn, tag)
1155 chain = str(groups.group(1))
1156 node = str(groups.group(2))
1160 groups = re.search(regex_test_name, test[u"name"])
1161 if groups and len(groups.groups()) == 3:
1163 f"{str(groups.group(1))}-"
1164 f"{str(groups.group(2))}-"
1165 f"{str(groups.group(3))}"
1169 if vals.get(chain, None) is None:
1170 vals[chain] = dict()
1171 if vals[chain].get(node, None) is None:
1172 vals[chain][node] = dict(
1180 if plot[u"include-tests"] == u"MRR":
1181 result = test[u"result"][u"receive-rate"]
1182 elif plot[u"include-tests"] == u"PDR":
1183 result = test[u"throughput"][u"PDR"][u"LOWER"]
1184 elif plot[u"include-tests"] == u"NDR":
1185 result = test[u"throughput"][u"NDR"][u"LOWER"]
1192 vals[chain][node][u"vals"].append(result)
1195 logging.error(u"No data.")
1201 txt_chains.append(key_c)
1202 for key_n in vals[key_c].keys():
1203 txt_nodes.append(key_n)
1204 if vals[key_c][key_n][u"vals"]:
1205 vals[key_c][key_n][u"nr"] = len(vals[key_c][key_n][u"vals"])
1206 vals[key_c][key_n][u"mean"] = \
1207 round(mean(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1208 vals[key_c][key_n][u"stdev"] = \
1209 round(stdev(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1210 txt_nodes = list(set(txt_nodes))
1212 def sort_by_int(value):
1213 """Makes possible to sort a list of strings which represent integers.
1215 :param value: Integer as a string.
1217 :returns: Integer representation of input parameter 'value'.
1222 txt_chains = sorted(txt_chains, key=sort_by_int)
1223 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1225 chains = [i + 1 for i in range(len(txt_chains))]
1226 nodes = [i + 1 for i in range(len(txt_nodes))]
1228 data = [list() for _ in range(len(chains))]
1229 for chain in chains:
1232 val = vals[txt_chains[chain - 1]][txt_nodes[node - 1]][u"mean"]
1233 except (KeyError, IndexError):
1235 data[chain - 1].append(val)
1238 my_green = [[0.0, u"rgb(235, 249, 242)"],
1239 [1.0, u"rgb(45, 134, 89)"]]
1241 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1242 [1.0, u"rgb(57, 115, 172)"]]
1244 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1245 [1.0, u"rgb(102, 102, 102)"]]
1248 annotations = list()
1250 text = (u"Test: {name}<br>"
1255 for chain, _ in enumerate(txt_chains):
1257 for node, _ in enumerate(txt_nodes):
1258 if data[chain][node] is not None:
1267 text=str(data[chain][node]),
1275 hover_line.append(text.format(
1276 name=vals[txt_chains[chain]][txt_nodes[node]][u"name"],
1277 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1278 val=data[chain][node],
1279 stdev=vals[txt_chains[chain]][txt_nodes[node]][u"stdev"]))
1280 hovertext.append(hover_line)
1288 title=plot.get(u"z-axis", u""),
1302 colorscale=my_green,
1308 for idx, item in enumerate(txt_nodes):
1326 for idx, item in enumerate(txt_chains):
1353 text=plot.get(u"x-axis", u""),
1370 text=plot.get(u"y-axis", u""),
1379 updatemenus = list([
1390 u"colorscale": [my_green, ],
1391 u"reversescale": False
1400 u"colorscale": [my_blue, ],
1401 u"reversescale": False
1410 u"colorscale": [my_grey, ],
1411 u"reversescale": False
1422 layout = deepcopy(plot[u"layout"])
1423 except KeyError as err:
1424 logging.error(f"Finished with error: No layout defined\n{repr(err)}")
1427 layout[u"annotations"] = annotations
1428 layout[u'updatemenus'] = updatemenus
1432 plpl = plgo.Figure(data=traces, layout=layout)
1435 logging.info(f" Writing file {plot[u'output-file']}.html")
1440 filename=f"{plot[u'output-file']}.html"
1442 except PlotlyError as err:
1444 f" Finished with error: {repr(err)}".replace(u"\n", u" ")