1 # Copyright (c) 2021 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]*)-')
64 # This value depends on latency stream rate (9001 pps) and duration (5s).
65 # Keep it slightly higher to ensure rounding errors to not remove tick mark.
66 PERCENTILE_MAX = 99.999501
69 def generate_plots(spec, data):
70 """Generate all plots specified in the specification file.
72 :param spec: Specification read from the specification file.
73 :param data: Data to process.
74 :type spec: Specification
79 u"plot_nf_reconf_box_name": plot_nf_reconf_box_name,
80 u"plot_perf_box_name": plot_perf_box_name,
81 u"plot_tsa_name": plot_tsa_name,
82 u"plot_http_server_perf_box": plot_http_server_perf_box,
83 u"plot_nf_heatmap": plot_nf_heatmap,
84 u"plot_hdrh_lat_by_percentile": plot_hdrh_lat_by_percentile,
85 u"plot_hdrh_lat_by_percentile_x_log": plot_hdrh_lat_by_percentile_x_log,
86 u"plot_mrr_error_bars_name": plot_mrr_error_bars_name,
87 u"plot_mrr_box_name": plot_mrr_box_name
90 logging.info(u"Generating the plots ...")
91 for index, plot in enumerate(spec.plots):
93 logging.info(f" Plot nr {index + 1}: {plot.get(u'title', u'')}")
94 plot[u"limits"] = spec.configuration[u"limits"]
95 generator[plot[u"algorithm"]](plot, data)
96 logging.info(u" Done.")
97 except NameError as err:
99 f"Probably algorithm {plot[u'algorithm']} is not defined: "
102 logging.info(u"Done.")
105 def plot_hdrh_lat_by_percentile(plot, input_data):
106 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile
107 specified in the specification file.
109 :param plot: Plot to generate.
110 :param input_data: Data to process.
111 :type plot: pandas.Series
112 :type input_data: InputData
117 f" Creating the data set for the {plot.get(u'type', u'')} "
118 f"{plot.get(u'title', u'')}."
120 if plot.get(u"include", None):
121 data = input_data.filter_tests_by_name(
123 params=[u"name", u"latency", u"parent", u"tags", u"type"]
125 elif plot.get(u"filter", None):
126 data = input_data.filter_data(
128 params=[u"name", u"latency", u"parent", u"tags", u"type"],
129 continue_on_error=True
132 job = list(plot[u"data"].keys())[0]
133 build = str(plot[u"data"][job][0])
134 data = input_data.tests(job, build)
136 if data is None or len(data) == 0:
137 logging.error(u"No data.")
141 u"LAT0": u"No-load.",
142 u"PDR10": u"Low-load, 10% PDR.",
143 u"PDR50": u"Mid-load, 50% PDR.",
144 u"PDR90": u"High-load, 90% PDR.",
145 u"PDR": u"Full-load, 100% PDR.",
146 u"NDR10": u"Low-load, 10% NDR.",
147 u"NDR50": u"Mid-load, 50% NDR.",
148 u"NDR90": u"High-load, 90% NDR.",
149 u"NDR": u"Full-load, 100% NDR."
159 file_links = plot.get(u"output-file-links", None)
160 target_links = plot.get(u"target-links", None)
164 if test[u"type"] not in (u"NDRPDR",):
165 logging.warning(f"Invalid test type: {test[u'type']}")
167 name = re.sub(REGEX_NIC, u"", test[u"parent"].
168 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
170 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
171 except (IndexError, AttributeError, KeyError, ValueError):
173 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
175 logging.info(f" Generating the graph: {name_link}")
178 layout = deepcopy(plot[u"layout"])
180 for color, graph in enumerate(graphs):
181 for idx, direction in enumerate((u"direction1", u"direction2")):
187 decoded = hdrh.histogram.HdrHistogram.decode(
188 test[u"latency"][graph][direction][u"hdrh"]
190 except hdrh.codec.HdrLengthException:
192 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
196 for item in decoded.get_recorded_iterator():
197 percentile = item.percentile_level_iterated_to
198 xaxis.append(previous_x)
199 yaxis.append(item.value_iterated_to)
201 f"<b>{desc[graph]}</b><br>"
202 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
203 f"Percentile: {previous_x:.5f}-{percentile:.5f}%<br>"
204 f"Latency: {item.value_iterated_to}uSec"
206 xaxis.append(percentile)
207 yaxis.append(item.value_iterated_to)
209 f"<b>{desc[graph]}</b><br>"
210 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
211 f"Percentile: {previous_x:.5f}-{percentile:.5f}%<br>"
212 f"Latency: {item.value_iterated_to}uSec"
214 previous_x = percentile
221 legendgroup=desc[graph],
222 showlegend=bool(idx),
226 width=1 if idx % 2 else 2
233 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
234 fig.update_layout(layout)
237 file_name = f"{plot[u'output-file']}-{name_link}.html"
238 logging.info(f" Writing file {file_name}")
242 ploff.plot(fig, show_link=False, auto_open=False,
244 # Add link to the file:
245 if file_links and target_links:
246 with open(file_links, u"a") as file_handler:
249 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
251 except FileNotFoundError as err:
253 f"Not possible to write the link to the file "
254 f"{file_links}\n{err}"
256 except PlotlyError as err:
257 logging.error(f" Finished with error: {repr(err)}")
259 except hdrh.codec.HdrLengthException as err:
260 logging.warning(repr(err))
263 except (ValueError, KeyError) as err:
264 logging.warning(repr(err))
268 def plot_hdrh_lat_by_percentile_x_log(plot, input_data):
269 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile_x_log
270 specified in the specification file.
272 :param plot: Plot to generate.
273 :param input_data: Data to process.
274 :type plot: pandas.Series
275 :type input_data: InputData
280 f" Creating the data set for the {plot.get(u'type', u'')} "
281 f"{plot.get(u'title', u'')}."
283 if plot.get(u"include", None):
284 data = input_data.filter_tests_by_name(
286 params=[u"name", u"latency", u"parent", u"tags", u"type"]
288 elif plot.get(u"filter", None):
289 data = input_data.filter_data(
291 params=[u"name", u"latency", u"parent", u"tags", u"type"],
292 continue_on_error=True
295 job = list(plot[u"data"].keys())[0]
296 build = str(plot[u"data"][job][0])
297 data = input_data.tests(job, build)
299 if data is None or len(data) == 0:
300 logging.error(u"No data.")
304 u"LAT0": u"No-load.",
305 u"PDR10": u"Low-load, 10% PDR.",
306 u"PDR50": u"Mid-load, 50% PDR.",
307 u"PDR90": u"High-load, 90% PDR.",
308 u"PDR": u"Full-load, 100% PDR.",
309 u"NDR10": u"Low-load, 10% NDR.",
310 u"NDR50": u"Mid-load, 50% NDR.",
311 u"NDR90": u"High-load, 90% NDR.",
312 u"NDR": u"Full-load, 100% NDR."
322 file_links = plot.get(u"output-file-links", None)
323 target_links = plot.get(u"target-links", None)
327 if test[u"type"] not in (u"NDRPDR",):
328 logging.warning(f"Invalid test type: {test[u'type']}")
330 name = re.sub(REGEX_NIC, u"", test[u"parent"].
331 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
333 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
334 except (IndexError, AttributeError, KeyError, ValueError):
336 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
338 logging.info(f" Generating the graph: {name_link}")
341 layout = deepcopy(plot[u"layout"])
343 for color, graph in enumerate(graphs):
344 for idx, direction in enumerate((u"direction1", u"direction2")):
351 decoded = hdrh.histogram.HdrHistogram.decode(
352 test[u"latency"][graph][direction][u"hdrh"]
354 except hdrh.codec.HdrLengthException:
356 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
360 for item in decoded.get_recorded_iterator():
361 # The real value is "percentile".
362 # For 100%, we cut that down to "x_perc" to avoid
364 percentile = item.percentile_level_iterated_to
365 x_perc = min(percentile, PERCENTILE_MAX)
366 xaxis.append(previous_x)
367 yaxis.append(item.value_iterated_to)
369 f"<b>{desc[graph]}</b><br>"
370 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
371 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
372 f"Latency: {item.value_iterated_to}uSec"
374 next_x = 100.0 / (100.0 - x_perc)
376 yaxis.append(item.value_iterated_to)
378 f"<b>{desc[graph]}</b><br>"
379 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
380 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
381 f"Latency: {item.value_iterated_to}uSec"
384 prev_perc = percentile
391 legendgroup=desc[graph],
392 showlegend=not(bool(idx)),
396 width=1 if idx % 2 else 2
403 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
404 x_max = log(100.0 / (100.0 - PERCENTILE_MAX), 10)
405 layout[u"xaxis"][u"range"] = [0, x_max]
406 fig.update_layout(layout)
409 file_name = f"{plot[u'output-file']}-{name_link}.html"
410 logging.info(f" Writing file {file_name}")
414 ploff.plot(fig, show_link=False, auto_open=False,
416 # Add link to the file:
417 if file_links and target_links:
418 with open(file_links, u"a") as file_handler:
421 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
423 except FileNotFoundError as err:
425 f"Not possible to write the link to the file "
426 f"{file_links}\n{err}"
428 except PlotlyError as err:
429 logging.error(f" Finished with error: {repr(err)}")
431 except hdrh.codec.HdrLengthException as err:
432 logging.warning(repr(err))
435 except (ValueError, KeyError) as err:
436 logging.warning(repr(err))
440 def plot_nf_reconf_box_name(plot, input_data):
441 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
442 specified in the specification file.
444 :param plot: Plot to generate.
445 :param input_data: Data to process.
446 :type plot: pandas.Series
447 :type input_data: InputData
452 f" Creating the data set for the {plot.get(u'type', u'')} "
453 f"{plot.get(u'title', u'')}."
455 data = input_data.filter_tests_by_name(
456 plot, params=[u"result", u"parent", u"tags", u"type"]
459 logging.error(u"No data.")
462 # Prepare the data for the plot
463 y_vals = OrderedDict()
468 if y_vals.get(test[u"parent"], None) is None:
469 y_vals[test[u"parent"]] = list()
470 loss[test[u"parent"]] = list()
472 y_vals[test[u"parent"]].append(test[u"result"][u"time"])
473 loss[test[u"parent"]].append(test[u"result"][u"loss"])
474 except (KeyError, TypeError):
475 y_vals[test[u"parent"]].append(None)
477 # Add None to the lists with missing data
479 nr_of_samples = list()
480 for val in y_vals.values():
481 if len(val) > max_len:
483 nr_of_samples.append(len(val))
484 for val in y_vals.values():
485 if len(val) < max_len:
486 val.extend([None for _ in range(max_len - len(val))])
490 df_y = pd.DataFrame(y_vals)
492 for i, col in enumerate(df_y.columns):
494 tst_name = re.sub(REGEX_NIC, u"",
495 col.lower().replace(u'-reconf', u'').
496 replace(u'2n1l-', u'').replace(u'2n-', u'').
497 replace(u'-testpmd', u''))
499 traces.append(plgo.Box(
500 x=[str(i + 1) + u'.'] * len(df_y[col]),
504 f"({nr_of_samples[i]:02d} "
505 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
506 f"packets lost average: {mean(loss[col]):.1f}) "
507 f"{u'-'.join(tst_name.split(u'-')[2:])}"
513 layout = deepcopy(plot[u"layout"])
514 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
515 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
516 layout[u"legend"][u"font"][u"size"] = 14
517 layout[u"yaxis"].pop(u"range")
518 plpl = plgo.Figure(data=traces, layout=layout)
521 file_type = plot.get(u"output-file-type", u".html")
522 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
527 filename=f"{plot[u'output-file']}{file_type}"
529 except PlotlyError as err:
531 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
536 def plot_perf_box_name(plot, input_data):
537 """Generate the plot(s) with algorithm: plot_perf_box_name
538 specified in the specification file.
540 :param plot: Plot to generate.
541 :param input_data: Data to process.
542 :type plot: pandas.Series
543 :type input_data: InputData
548 f" Creating data set for the {plot.get(u'type', u'')} "
549 f"{plot.get(u'title', u'')}."
551 data = input_data.filter_tests_by_name(
553 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
555 logging.error(u"No data.")
558 # Prepare the data for the plot
559 plot_title = plot.get(u"title", u"").lower()
561 if u"-gbps" in plot_title:
565 value = u"throughput"
567 y_vals = OrderedDict()
570 for item in plot.get(u"include", tuple()):
571 reg_ex = re.compile(str(item).lower())
574 for test_id, test in build.iteritems():
575 if not re.match(reg_ex, str(test_id).lower()):
577 if y_vals.get(test[u"parent"], None) is None:
578 y_vals[test[u"parent"]] = list()
580 if test[u"type"] in (u"NDRPDR", u"CPS"):
581 test_type = test[u"type"]
583 if u"-pdr" in plot_title:
585 elif u"-ndr" in plot_title:
589 u"Wrong title. No information about test "
590 u"type. Add '-ndr' or '-pdr' to the test "
594 y_vals[test[u"parent"]].append(
595 test[value][ttype][u"LOWER"] * multiplier
598 elif test[u"type"] in (u"SOAK",):
599 y_vals[test[u"parent"]]. \
600 append(test[u"throughput"][u"LOWER"])
603 elif test[u"type"] in (u"HOSTSTACK",):
604 if u"LDPRELOAD" in test[u"tags"]:
605 y_vals[test[u"parent"]].append(
607 test[u"result"][u"bits_per_second"]
610 elif u"VPPECHO" in test[u"tags"]:
611 y_vals[test[u"parent"]].append(
613 test[u"result"][u"client"][u"tx_data"]
616 test[u"result"][u"client"][u"time"]
619 test[u"result"][u"server"][u"time"])
622 test_type = u"HOSTSTACK"
627 except (KeyError, TypeError):
628 y_vals[test[u"parent"]].append(None)
630 # Add None to the lists with missing data
632 nr_of_samples = list()
633 for val in y_vals.values():
634 if len(val) > max_len:
636 nr_of_samples.append(len(val))
637 for val in y_vals.values():
638 if len(val) < max_len:
639 val.extend([None for _ in range(max_len - len(val))])
643 df_y = pd.DataFrame(y_vals)
646 for i, col in enumerate(df_y.columns):
647 tst_name = re.sub(REGEX_NIC, u"",
648 col.lower().replace(u'-ndrpdr', u'').
649 replace(u'2n1l-', u''))
651 x=[str(i + 1) + u'.'] * len(df_y[col]),
652 y=[y / 1e6 if y else None for y in df_y[col]],
655 f"({nr_of_samples[i]:02d} "
656 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
661 if test_type in (u"SOAK", ):
662 kwargs[u"boxpoints"] = u"all"
664 traces.append(plgo.Box(**kwargs))
667 val_max = max(df_y[col])
669 y_max.append(int(val_max / 1e6) + 2)
670 except (ValueError, TypeError) as err:
671 logging.error(repr(err))
676 layout = deepcopy(plot[u"layout"])
677 if layout.get(u"title", None):
678 if test_type in (u"HOSTSTACK", ):
679 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
680 elif test_type in (u"CPS", ):
681 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
683 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
685 layout[u"yaxis"][u"range"] = [0, max(y_max)]
686 plpl = plgo.Figure(data=traces, layout=layout)
689 logging.info(f" Writing file {plot[u'output-file']}.html.")
694 filename=f"{plot[u'output-file']}.html"
696 except PlotlyError as err:
698 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
703 def plot_mrr_box_name(plot, input_data):
704 """Generate the plot(s) with algorithm: plot_mrr_box_name
705 specified in the specification file.
707 :param plot: Plot to generate.
708 :param input_data: Data to process.
709 :type plot: pandas.Series
710 :type input_data: InputData
715 f" Creating data set for the {plot.get(u'type', u'')} "
716 f"{plot.get(u'title', u'')}."
718 data = input_data.filter_tests_by_name(
720 params=[u"result", u"parent", u"tags", u"type"])
722 logging.error(u"No data.")
725 # Prepare the data for the plot
731 for item in plot.get(u"include", tuple()):
732 reg_ex = re.compile(str(item).lower())
735 for test_id, test in build.iteritems():
736 if not re.match(reg_ex, str(test_id).lower()):
740 name = re.sub(REGEX_NIC, u'', test[u'parent'].lower().
741 replace(u'-mrr', u'').
742 replace(u'2n1l-', u''))
743 data_y.append(test[u"result"][u"samples"])
746 f"({len(data_y[-1]):02d} "
747 f"run{u's' if len(data_y[-1]) > 1 else u''}) "
750 data_y_max.append(max(test[u"result"][u"samples"]))
752 except (KeyError, TypeError):
757 for idx in range(len(data_x)):
760 x=[data_x[idx], ] * len(data_y[idx]),
762 name=data_names[idx],
769 layout = deepcopy(plot[u"layout"])
770 if layout.get(u"title", None):
771 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
773 layout[u"yaxis"][u"range"] = [0, max(data_y_max) + 1]
774 plpl = plgo.Figure(data=traces, layout=layout)
777 logging.info(f" Writing file {plot[u'output-file']}.html.")
782 filename=f"{plot[u'output-file']}.html"
784 except PlotlyError as err:
786 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
791 def plot_mrr_error_bars_name(plot, input_data):
792 """Generate the plot(s) with algorithm: plot_mrr_error_bars_name
793 specified in the specification file.
795 :param plot: Plot to generate.
796 :param input_data: Data to process.
797 :type plot: pandas.Series
798 :type input_data: InputData
803 f" Creating data set for the {plot.get(u'type', u'')} "
804 f"{plot.get(u'title', u'')}."
806 data = input_data.filter_tests_by_name(
808 params=[u"result", u"parent", u"tags", u"type"])
810 logging.error(u"No data.")
813 # Prepare the data for the plot
817 data_y_stdev = list()
821 for item in plot.get(u"include", tuple()):
822 reg_ex = re.compile(str(item).lower())
825 for test_id, test in build.iteritems():
826 if not re.match(reg_ex, str(test_id).lower()):
830 name = re.sub(REGEX_NIC, u'', test[u'parent'].lower().
831 replace(u'-mrr', u'').
832 replace(u'2n1l-', u''))
833 data_names.append(f"{idx}. {name}")
835 round(test[u"result"][u"receive-rate"], 3)
838 round(test[u"result"][u"receive-stdev"], 3)
841 f"{data_names[-1]}<br>"
842 f"average [Gbps]: {data_y_avg[-1]}<br>"
843 f"stdev [Gbps]: {data_y_stdev[-1]}"
845 if data_y_avg[-1] + data_y_stdev[-1] > data_y_max:
846 data_y_max = data_y_avg[-1] + data_y_stdev[-1]
848 except (KeyError, TypeError):
853 for idx in range(len(data_x)):
857 y=[data_y_avg[idx], ],
860 array=[data_y_stdev[idx], ],
863 name=data_names[idx],
865 text=hover_info[idx],
872 layout = deepcopy(plot[u"layout"])
873 if layout.get(u"title", None):
874 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
876 layout[u"yaxis"][u"range"] = [0, int(data_y_max) + 1]
877 plpl = plgo.Figure(data=traces, layout=layout)
880 logging.info(f" Writing file {plot[u'output-file']}.html.")
885 filename=f"{plot[u'output-file']}.html"
887 except PlotlyError as err:
889 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
894 def plot_tsa_name(plot, input_data):
895 """Generate the plot(s) with algorithm:
897 specified in the specification file.
899 :param plot: Plot to generate.
900 :param input_data: Data to process.
901 :type plot: pandas.Series
902 :type input_data: InputData
906 plot_title = plot.get(u"title", u"")
908 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
910 data = input_data.filter_tests_by_name(
912 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
915 logging.error(u"No data.")
918 plot_title = plot_title.lower()
920 if u"-gbps" in plot_title:
925 value = u"throughput"
929 y_vals = OrderedDict()
930 for item in plot.get(u"include", tuple()):
931 reg_ex = re.compile(str(item).lower())
934 for test_id, test in build.iteritems():
935 if re.match(reg_ex, str(test_id).lower()):
936 if y_vals.get(test[u"parent"], None) is None:
937 y_vals[test[u"parent"]] = {
943 if test[u"type"] not in (u"NDRPDR", u"CPS"):
946 if u"-pdr" in plot_title:
948 elif u"-ndr" in plot_title:
953 if u"1C" in test[u"tags"]:
954 y_vals[test[u"parent"]][u"1"].append(
955 test[value][ttype][u"LOWER"] * multiplier
957 elif u"2C" in test[u"tags"]:
958 y_vals[test[u"parent"]][u"2"].append(
959 test[value][ttype][u"LOWER"] * multiplier
961 elif u"4C" in test[u"tags"]:
962 y_vals[test[u"parent"]][u"4"].append(
963 test[value][ttype][u"LOWER"] * multiplier
965 except (KeyError, TypeError):
969 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
973 for test_name, test_vals in y_vals.items():
974 for key, test_val in test_vals.items():
976 avg_val = sum(test_val) / len(test_val)
977 y_vals[test_name][key] = [avg_val, len(test_val)]
978 ideal = avg_val / (int(key) * 1e6)
979 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
980 y_1c_max[test_name] = ideal
987 for test_name, test_vals in y_vals.items():
989 if test_vals[u"1"][1]:
993 test_name.replace(u'-ndrpdr', u'').replace(u'2n1l-', u'')
995 vals[name] = OrderedDict()
996 y_val_1 = test_vals[u"1"][0] / 1e6
997 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
999 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
1002 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
1003 vals[name][u"rel"] = [1.0, None, None]
1004 vals[name][u"ideal"] = [
1005 y_1c_max[test_name],
1006 y_1c_max[test_name] * 2,
1007 y_1c_max[test_name] * 4
1009 vals[name][u"diff"] = [
1010 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None
1012 vals[name][u"count"] = [
1019 val_max = max(vals[name][u"val"])
1020 except ValueError as err:
1021 logging.error(repr(err))
1024 y_max.append(val_max)
1027 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
1028 vals[name][u"diff"][1] = \
1029 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
1031 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
1032 vals[name][u"diff"][2] = \
1033 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
1034 except IndexError as err:
1035 logging.warning(f"No data for {test_name}")
1036 logging.warning(repr(err))
1039 if u"x520" in test_name:
1040 limit = plot[u"limits"][u"nic"][u"x520"]
1041 elif u"x710" in test_name:
1042 limit = plot[u"limits"][u"nic"][u"x710"]
1043 elif u"xxv710" in test_name:
1044 limit = plot[u"limits"][u"nic"][u"xxv710"]
1045 elif u"xl710" in test_name:
1046 limit = plot[u"limits"][u"nic"][u"xl710"]
1047 elif u"x553" in test_name:
1048 limit = plot[u"limits"][u"nic"][u"x553"]
1049 elif u"cx556a" in test_name:
1050 limit = plot[u"limits"][u"nic"][u"cx556a"]
1053 if limit > nic_limit:
1056 mul = 2 if u"ge2p" in test_name else 1
1057 if u"10ge" in test_name:
1058 limit = plot[u"limits"][u"link"][u"10ge"] * mul
1059 elif u"25ge" in test_name:
1060 limit = plot[u"limits"][u"link"][u"25ge"] * mul
1061 elif u"40ge" in test_name:
1062 limit = plot[u"limits"][u"link"][u"40ge"] * mul
1063 elif u"100ge" in test_name:
1064 limit = plot[u"limits"][u"link"][u"100ge"] * mul
1067 if limit > lnk_limit:
1070 if u"cx556a" in test_name:
1071 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
1073 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
1074 if limit > pci_limit:
1078 annotations = list()
1082 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
1086 min_limit = min((nic_limit, lnk_limit, pci_limit))
1087 if nic_limit == min_limit:
1088 traces.append(plgo.Scatter(
1090 y=[nic_limit, ] * len(x_vals),
1091 name=f"NIC: {nic_limit:.2f}Mpps",
1100 annotations.append(dict(
1107 text=f"NIC: {nic_limit:.2f}Mpps",
1115 y_max.append(nic_limit)
1116 elif lnk_limit == min_limit:
1117 traces.append(plgo.Scatter(
1119 y=[lnk_limit, ] * len(x_vals),
1120 name=f"Link: {lnk_limit:.2f}Mpps",
1129 annotations.append(dict(
1136 text=f"Link: {lnk_limit:.2f}Mpps",
1144 y_max.append(lnk_limit)
1145 elif pci_limit == min_limit:
1146 traces.append(plgo.Scatter(
1148 y=[pci_limit, ] * len(x_vals),
1149 name=f"PCIe: {pci_limit:.2f}Mpps",
1158 annotations.append(dict(
1165 text=f"PCIe: {pci_limit:.2f}Mpps",
1173 y_max.append(pci_limit)
1175 # Perfect and measured:
1177 for name, val in vals.items():
1180 for idx in range(len(val[u"val"])):
1182 if isinstance(val[u"val"][idx], float):
1184 f"No. of Runs: {val[u'count'][idx]}<br>"
1185 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
1187 if isinstance(val[u"diff"][idx], float):
1188 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
1189 if isinstance(val[u"rel"][idx], float):
1190 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
1191 hovertext.append(htext)
1198 mode=u"lines+markers",
1207 hoverinfo=u"text+name"
1214 name=f"{name} perfect",
1222 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1227 except (IndexError, ValueError, KeyError) as err:
1228 logging.warning(f"No data for {name}\n{repr(err)}")
1232 file_type = plot.get(u"output-file-type", u".html")
1233 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
1234 layout = deepcopy(plot[u"layout"])
1235 if layout.get(u"title", None):
1236 layout[u"title"] = f"<b>Speedup Multi-core:</b> {layout[u'title']}"
1237 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1238 layout[u"annotations"].extend(annotations)
1239 plpl = plgo.Figure(data=traces, layout=layout)
1246 filename=f"{plot[u'output-file']}{file_type}"
1248 except PlotlyError as err:
1250 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1255 def plot_http_server_perf_box(plot, input_data):
1256 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1257 specified in the specification file.
1259 :param plot: Plot to generate.
1260 :param input_data: Data to process.
1261 :type plot: pandas.Series
1262 :type input_data: InputData
1265 # Transform the data
1267 f" Creating the data set for the {plot.get(u'type', u'')} "
1268 f"{plot.get(u'title', u'')}."
1270 data = input_data.filter_data(plot)
1272 logging.error(u"No data.")
1275 # Prepare the data for the plot
1280 if y_vals.get(test[u"name"], None) is None:
1281 y_vals[test[u"name"]] = list()
1283 y_vals[test[u"name"]].append(test[u"result"])
1284 except (KeyError, TypeError):
1285 y_vals[test[u"name"]].append(None)
1287 # Add None to the lists with missing data
1289 nr_of_samples = list()
1290 for val in y_vals.values():
1291 if len(val) > max_len:
1293 nr_of_samples.append(len(val))
1294 for val in y_vals.values():
1295 if len(val) < max_len:
1296 val.extend([None for _ in range(max_len - len(val))])
1300 df_y = pd.DataFrame(y_vals)
1302 for i, col in enumerate(df_y.columns):
1305 f"({nr_of_samples[i]:02d} " \
1306 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1307 f"{col.lower().replace(u'-ndrpdr', u'')}"
1309 name_lst = name.split(u'-')
1312 for segment in name_lst:
1313 if (len(name) + len(segment) + 1) > 50 and split_name:
1316 name += segment + u'-'
1319 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1325 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1329 f" Writing file {plot[u'output-file']}"
1330 f"{plot[u'output-file-type']}."
1336 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1338 except PlotlyError as err:
1340 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1345 def plot_nf_heatmap(plot, input_data):
1346 """Generate the plot(s) with algorithm: plot_nf_heatmap
1347 specified in the specification file.
1349 :param plot: Plot to generate.
1350 :param input_data: Data to process.
1351 :type plot: pandas.Series
1352 :type input_data: InputData
1355 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1356 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1358 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1361 # Transform the data
1363 f" Creating the data set for the {plot.get(u'type', u'')} "
1364 f"{plot.get(u'title', u'')}."
1366 data = input_data.filter_data(plot, continue_on_error=True)
1367 if data is None or data.empty:
1368 logging.error(u"No data.")
1374 for tag in test[u"tags"]:
1375 groups = re.search(regex_cn, tag)
1377 chain = str(groups.group(1))
1378 node = str(groups.group(2))
1382 groups = re.search(regex_test_name, test[u"name"])
1383 if groups and len(groups.groups()) == 3:
1385 f"{str(groups.group(1))}-"
1386 f"{str(groups.group(2))}-"
1387 f"{str(groups.group(3))}"
1391 if vals.get(chain, None) is None:
1392 vals[chain] = dict()
1393 if vals[chain].get(node, None) is None:
1394 vals[chain][node] = dict(
1402 if plot[u"include-tests"] == u"MRR":
1403 result = test[u"result"][u"receive-rate"]
1404 elif plot[u"include-tests"] == u"PDR":
1405 result = test[u"throughput"][u"PDR"][u"LOWER"]
1406 elif plot[u"include-tests"] == u"NDR":
1407 result = test[u"throughput"][u"NDR"][u"LOWER"]
1414 vals[chain][node][u"vals"].append(result)
1417 logging.error(u"No data.")
1423 txt_chains.append(key_c)
1424 for key_n in vals[key_c].keys():
1425 txt_nodes.append(key_n)
1426 if vals[key_c][key_n][u"vals"]:
1427 vals[key_c][key_n][u"nr"] = len(vals[key_c][key_n][u"vals"])
1428 vals[key_c][key_n][u"mean"] = \
1429 round(mean(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1430 vals[key_c][key_n][u"stdev"] = \
1431 round(stdev(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1432 txt_nodes = list(set(txt_nodes))
1434 def sort_by_int(value):
1435 """Makes possible to sort a list of strings which represent integers.
1437 :param value: Integer as a string.
1439 :returns: Integer representation of input parameter 'value'.
1444 txt_chains = sorted(txt_chains, key=sort_by_int)
1445 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1447 chains = [i + 1 for i in range(len(txt_chains))]
1448 nodes = [i + 1 for i in range(len(txt_nodes))]
1450 data = [list() for _ in range(len(chains))]
1451 for chain in chains:
1454 val = vals[txt_chains[chain - 1]][txt_nodes[node - 1]][u"mean"]
1455 except (KeyError, IndexError):
1457 data[chain - 1].append(val)
1460 my_green = [[0.0, u"rgb(235, 249, 242)"],
1461 [1.0, u"rgb(45, 134, 89)"]]
1463 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1464 [1.0, u"rgb(57, 115, 172)"]]
1466 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1467 [1.0, u"rgb(102, 102, 102)"]]
1470 annotations = list()
1472 text = (u"Test: {name}<br>"
1477 for chain, _ in enumerate(txt_chains):
1479 for node, _ in enumerate(txt_nodes):
1480 if data[chain][node] is not None:
1489 text=str(data[chain][node]),
1497 hover_line.append(text.format(
1498 name=vals[txt_chains[chain]][txt_nodes[node]][u"name"],
1499 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1500 val=data[chain][node],
1501 stdev=vals[txt_chains[chain]][txt_nodes[node]][u"stdev"]))
1502 hovertext.append(hover_line)
1510 title=plot.get(u"z-axis", u""),
1524 colorscale=my_green,
1530 for idx, item in enumerate(txt_nodes):
1548 for idx, item in enumerate(txt_chains):
1575 text=plot.get(u"x-axis", u""),
1592 text=plot.get(u"y-axis", u""),
1601 updatemenus = list([
1612 u"colorscale": [my_green, ],
1613 u"reversescale": False
1622 u"colorscale": [my_blue, ],
1623 u"reversescale": False
1632 u"colorscale": [my_grey, ],
1633 u"reversescale": False
1644 layout = deepcopy(plot[u"layout"])
1645 except KeyError as err:
1646 logging.error(f"Finished with error: No layout defined\n{repr(err)}")
1649 layout[u"annotations"] = annotations
1650 layout[u'updatemenus'] = updatemenus
1654 plpl = plgo.Figure(data=traces, layout=layout)
1657 logging.info(f" Writing file {plot[u'output-file']}.html")
1662 filename=f"{plot[u'output-file']}.html"
1664 except PlotlyError as err:
1666 f" Finished with error: {repr(err)}".replace(u"\n", u" ")