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_box_name": plot_mrr_box_name,
87 u"plot_ndrpdr_box_name": plot_ndrpdr_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 for core in plot.get(u"core", tuple()):
463 # Prepare the data for the plot
464 y_vals = OrderedDict()
466 for item in plot.get(u"include", tuple()):
467 reg_ex = re.compile(str(item.format(core=core)).lower())
470 for test_id, test in build.iteritems():
471 if not re.match(reg_ex, str(test_id).lower()):
473 if y_vals.get(test[u"parent"], None) is None:
474 y_vals[test[u"parent"]] = list()
475 loss[test[u"parent"]] = list()
477 y_vals[test[u"parent"]].append(
478 test[u"result"][u"time"]
480 loss[test[u"parent"]].append(
481 test[u"result"][u"loss"]
483 except (KeyError, TypeError):
484 y_vals[test[u"parent"]].append(None)
486 # Add None to the lists with missing data
488 nr_of_samples = list()
489 for val in y_vals.values():
490 if len(val) > max_len:
492 nr_of_samples.append(len(val))
493 for val in y_vals.values():
494 if len(val) < max_len:
495 val.extend([None for _ in range(max_len - len(val))])
499 df_y = pd.DataFrame(y_vals)
501 for i, col in enumerate(df_y.columns):
504 col.lower().replace(u'-reconf', u'').replace(u'2n1l-', u'').
505 replace(u'2n-', u'').replace(u'-testpmd', u'')
507 traces.append(plgo.Box(
508 x=[str(i + 1) + u'.'] * len(df_y[col]),
512 f"({nr_of_samples[i]:02d} "
513 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
514 f"packets lost average: {mean(loss[col]):.1f}) "
515 f"{u'-'.join(tst_name.split(u'-')[2:])}"
521 layout = deepcopy(plot[u"layout"])
522 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
523 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
524 layout[u"legend"][u"font"][u"size"] = 14
525 layout[u"yaxis"].pop(u"range")
526 plpl = plgo.Figure(data=traces, layout=layout)
529 file_name = f"{plot[u'output-file'].format(core=core)}.html"
530 logging.info(f" Writing file {file_name}")
537 except PlotlyError as err:
539 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
543 def plot_perf_box_name(plot, input_data):
544 """Generate the plot(s) with algorithm: plot_perf_box_name
545 specified in the specification file.
547 Use only for soak and hoststack tests.
549 :param plot: Plot to generate.
550 :param input_data: Data to process.
551 :type plot: pandas.Series
552 :type input_data: InputData
557 f" Creating data set for the {plot.get(u'type', u'')} "
558 f"{plot.get(u'title', u'')}."
560 data = input_data.filter_tests_by_name(
562 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
564 logging.error(u"No data.")
567 # Prepare the data for the plot
568 y_vals = OrderedDict()
571 for item in plot.get(u"include", tuple()):
572 reg_ex = re.compile(str(item).lower())
575 for test_id, test in build.iteritems():
576 if not re.match(reg_ex, str(test_id).lower()):
578 if y_vals.get(test[u"parent"], None) is None:
579 y_vals[test[u"parent"]] = list()
581 if test[u"type"] in (u"SOAK",):
582 y_vals[test[u"parent"]]. \
583 append(test[u"throughput"][u"LOWER"])
586 elif test[u"type"] in (u"HOSTSTACK",):
587 if u"LDPRELOAD" in test[u"tags"]:
588 y_vals[test[u"parent"]].append(
590 test[u"result"][u"bits_per_second"]
593 elif u"VPPECHO" in test[u"tags"]:
594 y_vals[test[u"parent"]].append(
596 test[u"result"][u"client"][u"tx_data"]
599 test[u"result"][u"client"][u"time"]
602 test[u"result"][u"server"][u"time"])
605 test_type = u"HOSTSTACK"
610 except (KeyError, TypeError):
611 y_vals[test[u"parent"]].append(None)
613 # Add None to the lists with missing data
615 nr_of_samples = list()
616 for val in y_vals.values():
617 if len(val) > max_len:
619 nr_of_samples.append(len(val))
620 for val in y_vals.values():
621 if len(val) < max_len:
622 val.extend([None for _ in range(max_len - len(val))])
626 df_y = pd.DataFrame(y_vals)
629 for i, col in enumerate(df_y.columns):
630 tst_name = re.sub(REGEX_NIC, u"",
631 col.lower().replace(u'-ndrpdr', u'').
632 replace(u'2n1l-', u''))
634 x=[str(i + 1) + u'.'] * len(df_y[col]),
635 y=[y / 1e6 if y else None for y in df_y[col]],
638 f"({nr_of_samples[i]:02d} "
639 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
644 if test_type in (u"SOAK", ):
645 kwargs[u"boxpoints"] = u"all"
647 traces.append(plgo.Box(**kwargs))
650 val_max = max(df_y[col])
652 y_max.append(int(val_max / 1e6) + 2)
653 except (ValueError, TypeError) as err:
654 logging.error(repr(err))
659 layout = deepcopy(plot[u"layout"])
660 if layout.get(u"title", None):
661 if test_type in (u"HOSTSTACK", ):
662 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
664 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
666 layout[u"yaxis"][u"range"] = [0, max(y_max)]
667 plpl = plgo.Figure(data=traces, layout=layout)
670 logging.info(f" Writing file {plot[u'output-file']}.html.")
675 filename=f"{plot[u'output-file']}.html"
677 except PlotlyError as err:
679 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
684 def plot_ndrpdr_box_name(plot, input_data):
685 """Generate the plot(s) with algorithm: plot_ndrpdr_box_name
686 specified in the specification file.
688 :param plot: Plot to generate.
689 :param input_data: Data to process.
690 :type plot: pandas.Series
691 :type input_data: InputData
696 f" Creating data set for the {plot.get(u'type', u'')} "
697 f"{plot.get(u'title', u'')}."
699 data = input_data.filter_tests_by_name(
701 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
704 logging.error(u"No data.")
707 if u"-gbps" in plot.get(u"title", u"").lower():
711 value = u"throughput"
716 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
717 for core in plot.get(u"core", tuple()):
718 # Prepare the data for the plot
720 data_y = OrderedDict()
723 for item in plot.get(u"include", tuple()):
724 reg_ex = re.compile(str(item.format(core=core)).lower())
727 for test_id, test in build.iteritems():
728 if not re.match(reg_ex, str(test_id).lower()):
730 if data_y.get(test[u"parent"], None) is None:
731 data_y[test[u"parent"]] = list()
732 test_type = test[u"type"]
736 data_y[test[u"parent"]].append(
737 test[value][ttype.upper()][u"LOWER"] *
740 except (KeyError, TypeError):
745 for idx, (key, vals) in enumerate(data_y.items()):
747 REGEX_NIC, u'', key.lower().replace(u'-ndrpdr', u'').
748 replace(u'2n1l-', u'')
752 x=[data_x[idx], ] * len(data_x),
753 y=[y / 1e6 if y else None for y in vals],
758 f"{u's' if len(vals) > 1 else u''}) "
764 data_y_max.append(max(vals))
768 layout = deepcopy(plot[u"layout"])
769 if layout.get(u"title", None):
771 layout[u'title'].format(core=core, test_type=ttype)
772 if test_type in (u"CPS", ):
773 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
776 f"<b>Throughput:</b> {layout[u'title']}"
778 layout[u"yaxis"][u"range"] = [0, max(data_y_max) / 1e6 + 1]
779 plpl = plgo.Figure(data=traces, layout=layout)
783 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
786 logging.info(f" Writing file {file_name}")
793 except PlotlyError as err:
795 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
799 def plot_mrr_box_name(plot, input_data):
800 """Generate the plot(s) with algorithm: plot_mrr_box_name
801 specified in the specification file.
803 :param plot: Plot to generate.
804 :param input_data: Data to process.
805 :type plot: pandas.Series
806 :type input_data: InputData
811 f" Creating data set for the {plot.get(u'type', u'')} "
812 f"{plot.get(u'title', u'')}."
814 data = input_data.filter_tests_by_name(
816 params=[u"result", u"parent", u"tags", u"type"]
819 logging.error(u"No data.")
822 for core in plot.get(u"core", tuple()):
823 # Prepare the data for the plot
829 for item in plot.get(u"include", tuple()):
830 reg_ex = re.compile(str(item.format(core=core)).lower())
833 for test_id, test in build.iteritems():
834 if not re.match(reg_ex, str(test_id).lower()):
839 REGEX_NIC, u'', test[u'parent'].lower().
840 replace(u'-mrr', u'').replace(u'2n1l-', u'')
842 data_y.append(test[u"result"][u"samples"])
845 f"({len(data_y[-1]):02d} "
846 f"run{u's' if len(data_y[-1]) > 1 else u''}) "
849 data_y_max.append(max(data_y[-1]))
851 except (KeyError, TypeError):
856 for idx in range(len(data_x)):
859 x=[data_x[idx], ] * len(data_y[idx]),
861 name=data_names[idx],
868 layout = deepcopy(plot[u"layout"])
869 if layout.get(u"title", None):
871 f"<b>Throughput:</b> {layout[u'title'].format(core=core)}"
874 layout[u"yaxis"][u"range"] = [0, max(data_y_max) + 1]
875 plpl = plgo.Figure(data=traces, layout=layout)
878 file_name = f"{plot[u'output-file'].format(core=core)}.html"
879 logging.info(f" Writing file {file_name}")
886 except PlotlyError as err:
888 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
892 def plot_tsa_name(plot, input_data):
893 """Generate the plot(s) with algorithm:
895 specified in the specification file.
897 :param plot: Plot to generate.
898 :param input_data: Data to process.
899 :type plot: pandas.Series
900 :type input_data: InputData
904 plot_title = plot.get(u"title", u"")
906 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
908 data = input_data.filter_tests_by_name(
910 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
913 logging.error(u"No data.")
916 plot_title = plot_title.lower()
918 if u"-gbps" in plot_title:
923 value = u"throughput"
927 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
928 y_vals = OrderedDict()
929 for item in plot.get(u"include", tuple()):
930 reg_ex = re.compile(str(item).lower())
933 for test_id, test in build.iteritems():
934 if re.match(reg_ex, str(test_id).lower()):
935 if y_vals.get(test[u"parent"], None) is None:
936 y_vals[test[u"parent"]] = {
942 if test[u"type"] not in (u"NDRPDR", u"CPS"):
945 if u"1C" in test[u"tags"]:
946 y_vals[test[u"parent"]][u"1"].append(
947 test[value][ttype.upper()][u"LOWER"] *
950 elif u"2C" in test[u"tags"]:
951 y_vals[test[u"parent"]][u"2"].append(
952 test[value][ttype.upper()][u"LOWER"] *
955 elif u"4C" in test[u"tags"]:
956 y_vals[test[u"parent"]][u"4"].append(
957 test[value][ttype.upper()][u"LOWER"] *
960 except (KeyError, TypeError):
964 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
968 for test_name, test_vals in y_vals.items():
969 for key, test_val in test_vals.items():
971 avg_val = sum(test_val) / len(test_val)
972 y_vals[test_name][key] = [avg_val, len(test_val)]
973 ideal = avg_val / (int(key) * 1e6)
974 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
975 y_1c_max[test_name] = ideal
982 for test_name, test_vals in y_vals.items():
984 if test_vals[u"1"][1]:
988 test_name.replace(u'-ndrpdr', u'').
989 replace(u'2n1l-', u'')
991 vals[name] = OrderedDict()
992 y_val_1 = test_vals[u"1"][0] / 1e6
993 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
995 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
998 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
999 vals[name][u"rel"] = [1.0, None, None]
1000 vals[name][u"ideal"] = [
1001 y_1c_max[test_name],
1002 y_1c_max[test_name] * 2,
1003 y_1c_max[test_name] * 4
1005 vals[name][u"diff"] = [
1006 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1,
1010 vals[name][u"count"] = [
1017 val_max = max(vals[name][u"val"])
1018 except ValueError as err:
1019 logging.error(repr(err))
1022 y_max.append(val_max)
1025 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
1026 vals[name][u"diff"][1] = \
1027 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
1029 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
1030 vals[name][u"diff"][2] = \
1031 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
1032 except IndexError as err:
1033 logging.warning(f"No data for {test_name}")
1034 logging.warning(repr(err))
1037 if u"x520" in test_name:
1038 limit = plot[u"limits"][u"nic"][u"x520"]
1039 elif u"x710" in test_name:
1040 limit = plot[u"limits"][u"nic"][u"x710"]
1041 elif u"xxv710" in test_name:
1042 limit = plot[u"limits"][u"nic"][u"xxv710"]
1043 elif u"xl710" in test_name:
1044 limit = plot[u"limits"][u"nic"][u"xl710"]
1045 elif u"x553" in test_name:
1046 limit = plot[u"limits"][u"nic"][u"x553"]
1047 elif u"cx556a" in test_name:
1048 limit = plot[u"limits"][u"nic"][u"cx556a"]
1049 elif u"e810cq" in test_name:
1050 limit = plot[u"limits"][u"nic"][u"e810cq"]
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_name = f"{plot[u'output-file'].format(test_type=ttype)}.html"
1233 logging.info(f" Writing file {file_name}")
1234 layout = deepcopy(plot[u"layout"])
1235 if layout.get(u"title", None):
1236 layout[u"title"] = (
1237 f"<b>Speedup Multi-core:</b> "
1238 f"{layout[u'title'].format(test_type=ttype)}"
1240 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1241 layout[u"annotations"].extend(annotations)
1242 plpl = plgo.Figure(data=traces, layout=layout)
1251 except PlotlyError as err:
1253 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1257 def plot_http_server_perf_box(plot, input_data):
1258 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1259 specified in the specification file.
1261 :param plot: Plot to generate.
1262 :param input_data: Data to process.
1263 :type plot: pandas.Series
1264 :type input_data: InputData
1267 # Transform the data
1269 f" Creating the data set for the {plot.get(u'type', u'')} "
1270 f"{plot.get(u'title', u'')}."
1272 data = input_data.filter_data(plot)
1274 logging.error(u"No data.")
1277 # Prepare the data for the plot
1282 if y_vals.get(test[u"name"], None) is None:
1283 y_vals[test[u"name"]] = list()
1285 y_vals[test[u"name"]].append(test[u"result"])
1286 except (KeyError, TypeError):
1287 y_vals[test[u"name"]].append(None)
1289 # Add None to the lists with missing data
1291 nr_of_samples = list()
1292 for val in y_vals.values():
1293 if len(val) > max_len:
1295 nr_of_samples.append(len(val))
1296 for val in y_vals.values():
1297 if len(val) < max_len:
1298 val.extend([None for _ in range(max_len - len(val))])
1302 df_y = pd.DataFrame(y_vals)
1304 for i, col in enumerate(df_y.columns):
1307 f"({nr_of_samples[i]:02d} " \
1308 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1309 f"{col.lower().replace(u'-ndrpdr', u'')}"
1311 name_lst = name.split(u'-')
1314 for segment in name_lst:
1315 if (len(name) + len(segment) + 1) > 50 and split_name:
1318 name += segment + u'-'
1321 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1327 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1331 f" Writing file {plot[u'output-file']}"
1332 f"{plot[u'output-file-type']}."
1338 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1340 except PlotlyError as err:
1342 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1347 def plot_nf_heatmap(plot, input_data):
1348 """Generate the plot(s) with algorithm: plot_nf_heatmap
1349 specified in the specification file.
1351 :param plot: Plot to generate.
1352 :param input_data: Data to process.
1353 :type plot: pandas.Series
1354 :type input_data: InputData
1357 def sort_by_int(value):
1358 """Makes possible to sort a list of strings which represent integers.
1360 :param value: Integer as a string.
1362 :returns: Integer representation of input parameter 'value'.
1367 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1368 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1370 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1373 # Transform the data
1375 f" Creating the data set for the {plot.get(u'type', u'')} "
1376 f"{plot.get(u'title', u'')}."
1378 in_data = input_data.filter_tests_by_name(
1380 continue_on_error=True,
1381 params=[u"throughput", u"result", u"name", u"tags", u"type"]
1383 if in_data is None or in_data.empty:
1384 logging.error(u"No data.")
1387 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
1388 for core in plot.get(u"core", tuple()):
1389 for item in plot.get(u"include", tuple()):
1390 reg_ex = re.compile(str(item.format(core=core)).lower())
1393 for test_id, test in build.iteritems():
1394 if not re.match(reg_ex, str(test_id).lower()):
1396 for tag in test[u"tags"]:
1397 groups = re.search(regex_cn, tag)
1399 chain = str(groups.group(1))
1400 node = str(groups.group(2))
1404 groups = re.search(regex_test_name, test[u"name"])
1405 if groups and len(groups.groups()) == 3:
1407 f"{str(groups.group(1))}-"
1408 f"{str(groups.group(2))}-"
1409 f"{str(groups.group(3))}"
1413 if vals.get(chain, None) is None:
1414 vals[chain] = dict()
1415 if vals[chain].get(node, None) is None:
1416 vals[chain][node] = dict(
1425 result = test[u"result"][u"receive-rate"]
1426 elif ttype == u"pdr":
1428 test[u"throughput"][u"PDR"][u"LOWER"]
1429 elif ttype == u"ndr":
1431 test[u"throughput"][u"NDR"][u"LOWER"]
1438 vals[chain][node][u"vals"].append(result)
1441 logging.error(u"No data.")
1447 txt_chains.append(key_c)
1448 for key_n in vals[key_c].keys():
1449 txt_nodes.append(key_n)
1450 if vals[key_c][key_n][u"vals"]:
1451 vals[key_c][key_n][u"nr"] = \
1452 len(vals[key_c][key_n][u"vals"])
1453 vals[key_c][key_n][u"mean"] = \
1454 round(mean(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1455 vals[key_c][key_n][u"stdev"] = \
1456 round(stdev(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1457 txt_nodes = list(set(txt_nodes))
1459 txt_chains = sorted(txt_chains, key=sort_by_int)
1460 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1462 chains = [i + 1 for i in range(len(txt_chains))]
1463 nodes = [i + 1 for i in range(len(txt_nodes))]
1465 data = [list() for _ in range(len(chains))]
1466 for chain in chains:
1469 val = vals[txt_chains[chain - 1]] \
1470 [txt_nodes[node - 1]][u"mean"]
1471 except (KeyError, IndexError):
1473 data[chain - 1].append(val)
1476 my_green = [[0.0, u"rgb(235, 249, 242)"],
1477 [1.0, u"rgb(45, 134, 89)"]]
1479 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1480 [1.0, u"rgb(57, 115, 172)"]]
1482 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1483 [1.0, u"rgb(102, 102, 102)"]]
1486 annotations = list()
1488 text = (u"Test: {name}<br>"
1493 for chain, _ in enumerate(txt_chains):
1495 for node, _ in enumerate(txt_nodes):
1496 if data[chain][node] is not None:
1505 text=str(data[chain][node]),
1513 hover_line.append(text.format(
1514 name=vals[txt_chains[chain]][txt_nodes[node]]
1516 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1517 val=data[chain][node],
1518 stdev=vals[txt_chains[chain]][txt_nodes[node]]
1521 hovertext.append(hover_line)
1529 title=plot.get(u"z-axis", u"{test_type}").
1530 format(test_type=ttype.upper()),
1544 colorscale=my_green,
1550 for idx, item in enumerate(txt_nodes):
1568 for idx, item in enumerate(txt_chains):
1595 text=plot.get(u"x-axis", u""),
1612 text=plot.get(u"y-axis", u""),
1621 updatemenus = list([
1632 u"colorscale": [my_green, ],
1633 u"reversescale": False
1642 u"colorscale": [my_blue, ],
1643 u"reversescale": False
1652 u"colorscale": [my_grey, ],
1653 u"reversescale": False
1664 layout = deepcopy(plot[u"layout"])
1665 except KeyError as err:
1667 f"Finished with error: No layout defined\n{repr(err)}"
1671 layout[u"annotations"] = annotations
1672 layout[u'updatemenus'] = updatemenus
1673 if layout.get(u"title", None):
1674 layout[u"title"] = layout[u'title'].replace(u"test_type", ttype)
1678 plpl = plgo.Figure(data=traces, layout=layout)
1682 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
1685 logging.info(f" Writing file {file_name}")
1692 except PlotlyError as err:
1694 f" Finished with error: {repr(err)}".replace(u"\n", u" ")