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.
21 from collections import OrderedDict
22 from copy import deepcopy
28 import plotly.offline as ploff
29 import plotly.graph_objs as plgo
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.environment[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>"
204 f"{previous_x:.5f}-{percentile:.5f}%<br>"
205 f"Latency: {item.value_iterated_to}uSec"
207 xaxis.append(percentile)
208 yaxis.append(item.value_iterated_to)
210 f"<b>{desc[graph]}</b><br>"
211 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
213 f"{previous_x:.5f}-{percentile:.5f}%<br>"
214 f"Latency: {item.value_iterated_to}uSec"
216 previous_x = percentile
223 legendgroup=desc[graph],
224 showlegend=bool(idx),
228 width=1 if idx % 2 else 2
235 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
236 fig.update_layout(layout)
239 file_name = f"{plot[u'output-file']}-{name_link}.html"
240 logging.info(f" Writing file {file_name}")
244 ploff.plot(fig, show_link=False, auto_open=False,
246 # Add link to the file:
247 if file_links and target_links:
248 with open(file_links, u"a") as file_handler:
251 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
253 except FileNotFoundError as err:
255 f"Not possible to write the link to the file "
256 f"{file_links}\n{err}"
258 except PlotlyError as err:
259 logging.error(f" Finished with error: {repr(err)}")
261 except hdrh.codec.HdrLengthException as err:
262 logging.warning(repr(err))
265 except (ValueError, KeyError) as err:
266 logging.warning(repr(err))
270 def plot_hdrh_lat_by_percentile_x_log(plot, input_data):
271 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile_x_log
272 specified in the specification file.
274 :param plot: Plot to generate.
275 :param input_data: Data to process.
276 :type plot: pandas.Series
277 :type input_data: InputData
282 f" Creating the data set for the {plot.get(u'type', u'')} "
283 f"{plot.get(u'title', u'')}."
285 if plot.get(u"include", None):
286 data = input_data.filter_tests_by_name(
288 params=[u"name", u"latency", u"parent", u"tags", u"type"]
290 elif plot.get(u"filter", None):
291 data = input_data.filter_data(
293 params=[u"name", u"latency", u"parent", u"tags", u"type"],
294 continue_on_error=True
297 job = list(plot[u"data"].keys())[0]
298 build = str(plot[u"data"][job][0])
299 data = input_data.tests(job, build)
301 if data is None or len(data) == 0:
302 logging.error(u"No data.")
306 u"LAT0": u"No-load.",
307 u"PDR10": u"Low-load, 10% PDR.",
308 u"PDR50": u"Mid-load, 50% PDR.",
309 u"PDR90": u"High-load, 90% PDR.",
310 u"PDR": u"Full-load, 100% PDR.",
311 u"NDR10": u"Low-load, 10% NDR.",
312 u"NDR50": u"Mid-load, 50% NDR.",
313 u"NDR90": u"High-load, 90% NDR.",
314 u"NDR": u"Full-load, 100% NDR."
324 file_links = plot.get(u"output-file-links", None)
325 target_links = plot.get(u"target-links", None)
329 if test[u"type"] not in (u"NDRPDR",):
330 logging.warning(f"Invalid test type: {test[u'type']}")
332 name = re.sub(REGEX_NIC, u"", test[u"parent"].
333 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
335 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
336 except (IndexError, AttributeError, KeyError, ValueError):
338 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
340 logging.info(f" Generating the graph: {name_link}")
343 layout = deepcopy(plot[u"layout"])
345 for color, graph in enumerate(graphs):
346 for idx, direction in enumerate((u"direction1", u"direction2")):
353 decoded = hdrh.histogram.HdrHistogram.decode(
354 test[u"latency"][graph][direction][u"hdrh"]
356 except (hdrh.codec.HdrLengthException, TypeError):
358 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
362 for item in decoded.get_recorded_iterator():
363 # The real value is "percentile".
364 # For 100%, we cut that down to "x_perc" to avoid
366 percentile = item.percentile_level_iterated_to
367 x_perc = min(percentile, PERCENTILE_MAX)
368 xaxis.append(previous_x)
369 yaxis.append(item.value_iterated_to)
371 f"<b>{desc[graph]}</b><br>"
372 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
373 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
374 f"Latency: {item.value_iterated_to}uSec"
376 next_x = 100.0 / (100.0 - x_perc)
378 yaxis.append(item.value_iterated_to)
380 f"<b>{desc[graph]}</b><br>"
381 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
382 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
383 f"Latency: {item.value_iterated_to}uSec"
386 prev_perc = percentile
393 legendgroup=desc[graph],
394 showlegend=not(bool(idx)),
398 width=1 if idx % 2 else 2
405 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
406 x_max = log(100.0 / (100.0 - PERCENTILE_MAX), 10)
407 layout[u"xaxis"][u"range"] = [0, x_max]
408 fig.update_layout(layout)
411 file_name = f"{plot[u'output-file']}-{name_link}.html"
412 logging.info(f" Writing file {file_name}")
416 ploff.plot(fig, show_link=False, auto_open=False,
418 # Add link to the file:
419 if file_links and target_links:
420 with open(file_links, u"a") as file_handler:
423 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
425 except FileNotFoundError as err:
427 f"Not possible to write the link to the file "
428 f"{file_links}\n{err}"
430 except PlotlyError as err:
431 logging.error(f" Finished with error: {repr(err)}")
433 except hdrh.codec.HdrLengthException as err:
434 logging.warning(repr(err))
437 except (ValueError, KeyError) as err:
438 logging.warning(repr(err))
442 def plot_nf_reconf_box_name(plot, input_data):
443 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
444 specified in the specification file.
446 :param plot: Plot to generate.
447 :param input_data: Data to process.
448 :type plot: pandas.Series
449 :type input_data: InputData
454 f" Creating the data set for the {plot.get(u'type', u'')} "
455 f"{plot.get(u'title', u'')}."
457 data = input_data.filter_tests_by_name(
458 plot, params=[u"result", u"parent", u"tags", u"type"]
461 logging.error(u"No data.")
464 for core in plot.get(u"core", tuple()):
465 # Prepare the data for the plot
466 y_vals = OrderedDict()
468 for item in plot.get(u"include", tuple()):
469 reg_ex = re.compile(str(item.format(core=core)).lower())
472 for test_id, test in build.iteritems():
473 if not re.match(reg_ex, str(test_id).lower()):
475 if y_vals.get(test[u"parent"], None) is None:
476 y_vals[test[u"parent"]] = list()
477 loss[test[u"parent"]] = list()
479 y_vals[test[u"parent"]].append(
480 test[u"result"][u"time"]
482 loss[test[u"parent"]].append(
483 test[u"result"][u"loss"]
485 except (KeyError, TypeError):
486 y_vals[test[u"parent"]].append(None)
488 # Add None to the lists with missing data
490 nr_of_samples = list()
491 for val in y_vals.values():
492 if len(val) > max_len:
494 nr_of_samples.append(len(val))
495 for val in y_vals.values():
496 if len(val) < max_len:
497 val.extend([None for _ in range(max_len - len(val))])
501 df_y = pd.DataFrame(y_vals)
503 for i, col in enumerate(df_y.columns):
506 col.lower().replace(u'-reconf', u'').replace(u'2n1l-', u'').
507 replace(u'2n-', u'').replace(u'-testpmd', u'')
509 traces.append(plgo.Box(
510 x=[str(i + 1) + u'.'] * len(df_y[col]),
514 f"({nr_of_samples[i]:02d} "
515 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
516 f"packets lost average: {mean(loss[col]):.1f}) "
517 f"{u'-'.join(tst_name.split(u'-')[2:])}"
523 layout = deepcopy(plot[u"layout"])
524 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
525 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
526 layout[u"legend"][u"font"][u"size"] = 14
527 layout[u"yaxis"].pop(u"range")
528 plpl = plgo.Figure(data=traces, layout=layout)
531 file_name = f"{plot[u'output-file'].format(core=core)}.html"
532 logging.info(f" Writing file {file_name}")
539 except PlotlyError as err:
541 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
545 def plot_perf_box_name(plot, input_data):
546 """Generate the plot(s) with algorithm: plot_perf_box_name
547 specified in the specification file.
549 Use only for soak and hoststack tests.
551 :param plot: Plot to generate.
552 :param input_data: Data to process.
553 :type plot: pandas.Series
554 :type input_data: InputData
559 f" Creating data set for the {plot.get(u'type', u'')} "
560 f"{plot.get(u'title', u'')}."
562 data = input_data.filter_tests_by_name(
564 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
566 logging.error(u"No data.")
569 # Prepare the data for the plot
570 y_vals = OrderedDict()
573 for item in plot.get(u"include", tuple()):
574 reg_ex = re.compile(str(item).lower())
577 for test_id, test in build.iteritems():
578 if not re.match(reg_ex, str(test_id).lower()):
580 if y_vals.get(test[u"parent"], None) is None:
581 y_vals[test[u"parent"]] = list()
583 if test[u"type"] in (u"SOAK",):
584 y_vals[test[u"parent"]]. \
585 append(test[u"throughput"][u"LOWER"])
588 elif test[u"type"] in (u"HOSTSTACK",):
589 if u"LDPRELOAD" in test[u"tags"]:
590 y_vals[test[u"parent"]].append(
592 test[u"result"][u"bits_per_second"]
595 elif u"VPPECHO" in test[u"tags"]:
596 y_vals[test[u"parent"]].append(
598 test[u"result"][u"client"][u"tx_data"]
601 test[u"result"][u"client"][u"time"]
604 test[u"result"][u"server"][u"time"])
607 test_type = u"HOSTSTACK"
612 except (KeyError, TypeError):
613 y_vals[test[u"parent"]].append(None)
615 # Add None to the lists with missing data
617 nr_of_samples = list()
618 for val in y_vals.values():
619 if len(val) > max_len:
621 nr_of_samples.append(len(val))
622 for val in y_vals.values():
623 if len(val) < max_len:
624 val.extend([None for _ in range(max_len - len(val))])
628 df_y = pd.DataFrame(y_vals)
631 for i, col in enumerate(df_y.columns):
632 tst_name = re.sub(REGEX_NIC, u"",
633 col.lower().replace(u'-ndrpdr', u'').
634 replace(u'2n1l-', u''))
636 x=[str(i + 1) + u'.'] * len(df_y[col]),
637 y=[y / 1e6 if y else None for y in df_y[col]],
640 f"({nr_of_samples[i]:02d} "
641 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
646 if test_type in (u"SOAK", ):
647 kwargs[u"boxpoints"] = u"all"
649 traces.append(plgo.Box(**kwargs))
652 val_max = max(df_y[col])
654 y_max.append(int(val_max / 1e6) + 2)
655 except (ValueError, TypeError) as err:
656 logging.error(repr(err))
661 layout = deepcopy(plot[u"layout"])
662 if layout.get(u"title", None):
663 if test_type in (u"HOSTSTACK", ):
664 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
666 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
668 layout[u"yaxis"][u"range"] = [0, max(y_max)]
669 plpl = plgo.Figure(data=traces, layout=layout)
672 logging.info(f" Writing file {plot[u'output-file']}.html.")
677 filename=f"{plot[u'output-file']}.html"
679 except PlotlyError as err:
681 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
686 def plot_ndrpdr_box_name(plot, input_data):
687 """Generate the plot(s) with algorithm: plot_ndrpdr_box_name
688 specified in the specification file.
690 :param plot: Plot to generate.
691 :param input_data: Data to process.
692 :type plot: pandas.Series
693 :type input_data: InputData
698 f" Creating data set for the {plot.get(u'type', u'')} "
699 f"{plot.get(u'title', u'')}."
701 data = input_data.filter_tests_by_name(
703 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
706 logging.error(u"No data.")
709 if u"-gbps" in plot.get(u"title", u"").lower():
713 value = u"throughput"
718 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
719 for core in plot.get(u"core", tuple()):
720 # Prepare the data for the plot
722 data_y = OrderedDict()
725 for item in plot.get(u"include", tuple()):
726 reg_ex = re.compile(str(item.format(core=core)).lower())
729 for test_id, test in build.iteritems():
730 if not re.match(reg_ex, str(test_id).lower()):
732 if data_y.get(test[u"parent"], None) is None:
733 data_y[test[u"parent"]] = list()
734 test_type = test[u"type"]
738 data_y[test[u"parent"]].append(
739 test[value][ttype.upper()][u"LOWER"] *
742 except (KeyError, TypeError):
747 for idx, (key, vals) in enumerate(data_y.items()):
749 REGEX_NIC, u'', key.lower().replace(u'-ndrpdr', u'').
750 replace(u'2n1l-', u'')
754 x=[data_x[idx], ] * len(data_x),
755 y=[y / 1e6 if y else None for y in vals],
760 f"{u's' if len(vals) > 1 else u''}) "
767 data_y_max.append(max(vals))
768 except ValueError as err:
769 logging.warning(f"No values to use.\n{err!r}")
772 layout = deepcopy(plot[u"layout"])
773 if layout.get(u"title", None):
775 layout[u'title'].format(core=core, test_type=ttype)
776 if test_type in (u"CPS", ):
777 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
780 f"<b>Throughput:</b> {layout[u'title']}"
782 layout[u"yaxis"][u"range"] = [0, max(data_y_max) / 1e6 + 1]
783 plpl = plgo.Figure(data=traces, layout=layout)
787 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
790 logging.info(f" Writing file {file_name}")
797 except PlotlyError as err:
799 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
803 def plot_mrr_box_name(plot, input_data):
804 """Generate the plot(s) with algorithm: plot_mrr_box_name
805 specified in the specification file.
807 :param plot: Plot to generate.
808 :param input_data: Data to process.
809 :type plot: pandas.Series
810 :type input_data: InputData
815 f" Creating data set for the {plot.get(u'type', u'')} "
816 f"{plot.get(u'title', u'')}."
818 data = input_data.filter_tests_by_name(
820 params=[u"result", u"parent", u"tags", u"type"]
823 logging.error(u"No data.")
826 for core in plot.get(u"core", tuple()):
827 # Prepare the data for the plot
833 for item in plot.get(u"include", tuple()):
834 reg_ex = re.compile(str(item.format(core=core)).lower())
837 for test_id, test in build.iteritems():
838 if not re.match(reg_ex, str(test_id).lower()):
843 REGEX_NIC, u'', test[u'parent'].lower().
844 replace(u'-mrr', u'').replace(u'2n1l-', u'')
846 data_y.append(test[u"result"][u"samples"])
849 f"({len(data_y[-1]):02d} "
850 f"run{u's' if len(data_y[-1]) > 1 else u''}) "
853 data_y_max.append(max(data_y[-1]))
855 except (KeyError, TypeError):
860 for idx, x_item in enumerate(data_x):
863 x=[x_item, ] * len(data_y[idx]),
865 name=data_names[idx],
872 layout = deepcopy(plot[u"layout"])
873 if layout.get(u"title", None):
875 f"<b>Throughput:</b> {layout[u'title'].format(core=core)}"
878 layout[u"yaxis"][u"range"] = [0, max(data_y_max) + 1]
879 plpl = plgo.Figure(data=traces, layout=layout)
882 file_name = f"{plot[u'output-file'].format(core=core)}.html"
883 logging.info(f" Writing file {file_name}")
890 except PlotlyError as err:
892 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
896 def plot_tsa_name(plot, input_data):
897 """Generate the plot(s) with algorithm:
899 specified in the specification file.
901 :param plot: Plot to generate.
902 :param input_data: Data to process.
903 :type plot: pandas.Series
904 :type input_data: InputData
908 plot_title = plot.get(u"title", u"")
910 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
912 data = input_data.filter_tests_by_name(
914 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
917 logging.error(u"No data.")
920 plot_title = plot_title.lower()
922 if u"-gbps" in plot_title:
927 value = u"throughput"
931 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
932 y_vals = OrderedDict()
933 for item in plot.get(u"include", tuple()):
934 reg_ex = re.compile(str(item).lower())
937 for test_id, test in build.iteritems():
938 if re.match(reg_ex, str(test_id).lower()):
939 if y_vals.get(test[u"parent"], None) is None:
940 y_vals[test[u"parent"]] = {
946 if test[u"type"] not in (u"NDRPDR", u"CPS"):
949 if u"1C" in test[u"tags"]:
950 y_vals[test[u"parent"]][u"1"].append(
951 test[value][ttype.upper()][u"LOWER"] *
954 elif u"2C" in test[u"tags"]:
955 y_vals[test[u"parent"]][u"2"].append(
956 test[value][ttype.upper()][u"LOWER"] *
959 elif u"4C" in test[u"tags"]:
960 y_vals[test[u"parent"]][u"4"].append(
961 test[value][ttype.upper()][u"LOWER"] *
964 except (KeyError, TypeError):
968 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
972 for test_name, test_vals in y_vals.items():
973 for key, test_val in test_vals.items():
975 avg_val = sum(test_val) / len(test_val)
976 y_vals[test_name][key] = [avg_val, len(test_val)]
977 ideal = avg_val / (int(key) * 1e6)
978 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
979 y_1c_max[test_name] = ideal
986 for test_name, test_vals in y_vals.items():
988 if test_vals[u"1"][1]:
992 test_name.replace(u'-ndrpdr', u'').
993 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,
1014 vals[name][u"count"] = [
1021 val_max = max(vals[name][u"val"])
1022 except ValueError as err:
1023 logging.error(repr(err))
1026 y_max.append(val_max)
1029 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
1030 vals[name][u"diff"][1] = \
1031 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
1033 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
1034 vals[name][u"diff"][2] = \
1035 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
1036 except IndexError as err:
1037 logging.warning(f"No data for {test_name}")
1038 logging.warning(repr(err))
1041 if u"x520" in test_name:
1042 limit = plot[u"limits"][u"nic"][u"x520"]
1043 elif u"x710" in test_name:
1044 limit = plot[u"limits"][u"nic"][u"x710"]
1045 elif u"xxv710" in test_name:
1046 limit = plot[u"limits"][u"nic"][u"xxv710"]
1047 elif u"xl710" in test_name:
1048 limit = plot[u"limits"][u"nic"][u"xl710"]
1049 elif u"x553" in test_name:
1050 limit = plot[u"limits"][u"nic"][u"x553"]
1051 elif u"cx556a" in test_name:
1052 limit = plot[u"limits"][u"nic"][u"cx556a"]
1053 elif u"e810cq" in test_name:
1054 limit = plot[u"limits"][u"nic"][u"e810cq"]
1057 if limit > nic_limit:
1060 mul = 2 if u"ge2p" in test_name else 1
1061 if u"10ge" in test_name:
1062 limit = plot[u"limits"][u"link"][u"10ge"] * mul
1063 elif u"25ge" in test_name:
1064 limit = plot[u"limits"][u"link"][u"25ge"] * mul
1065 elif u"40ge" in test_name:
1066 limit = plot[u"limits"][u"link"][u"40ge"] * mul
1067 elif u"100ge" in test_name:
1068 limit = plot[u"limits"][u"link"][u"100ge"] * mul
1071 if limit > lnk_limit:
1074 if u"cx556a" in test_name:
1075 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
1077 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
1078 if limit > pci_limit:
1082 annotations = list()
1086 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
1090 min_limit = min((nic_limit, lnk_limit, pci_limit))
1091 if nic_limit == min_limit:
1092 traces.append(plgo.Scatter(
1094 y=[nic_limit, ] * len(x_vals),
1095 name=f"NIC: {nic_limit:.2f}Mpps",
1104 annotations.append(dict(
1111 text=f"NIC: {nic_limit:.2f}Mpps",
1119 y_max.append(nic_limit)
1120 elif lnk_limit == min_limit:
1121 traces.append(plgo.Scatter(
1123 y=[lnk_limit, ] * len(x_vals),
1124 name=f"Link: {lnk_limit:.2f}Mpps",
1133 annotations.append(dict(
1140 text=f"Link: {lnk_limit:.2f}Mpps",
1148 y_max.append(lnk_limit)
1149 elif pci_limit == min_limit:
1150 traces.append(plgo.Scatter(
1152 y=[pci_limit, ] * len(x_vals),
1153 name=f"PCIe: {pci_limit:.2f}Mpps",
1162 annotations.append(dict(
1169 text=f"PCIe: {pci_limit:.2f}Mpps",
1177 y_max.append(pci_limit)
1179 # Perfect and measured:
1181 for name, val in vals.items():
1184 for idx in range(len(val[u"val"])):
1186 if isinstance(val[u"val"][idx], float):
1188 f"No. of Runs: {val[u'count'][idx]}<br>"
1189 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
1191 if isinstance(val[u"diff"][idx], float):
1192 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
1193 if isinstance(val[u"rel"][idx], float):
1194 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
1195 hovertext.append(htext)
1202 mode=u"lines+markers",
1211 hoverinfo=u"text+name"
1218 name=f"{name} perfect",
1226 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1231 except (IndexError, ValueError, KeyError) as err:
1232 logging.warning(f"No data for {name}\n{repr(err)}")
1236 file_name = f"{plot[u'output-file'].format(test_type=ttype)}.html"
1237 logging.info(f" Writing file {file_name}")
1238 layout = deepcopy(plot[u"layout"])
1239 if layout.get(u"title", None):
1240 layout[u"title"] = (
1241 f"<b>Speedup Multi-core:</b> "
1242 f"{layout[u'title'].format(test_type=ttype)}"
1244 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1245 layout[u"annotations"].extend(annotations)
1246 plpl = plgo.Figure(data=traces, layout=layout)
1255 except PlotlyError as err:
1257 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1261 def plot_http_server_perf_box(plot, input_data):
1262 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1263 specified in the specification file.
1265 :param plot: Plot to generate.
1266 :param input_data: Data to process.
1267 :type plot: pandas.Series
1268 :type input_data: InputData
1271 # Transform the data
1273 f" Creating the data set for the {plot.get(u'type', u'')} "
1274 f"{plot.get(u'title', u'')}."
1276 data = input_data.filter_data(plot)
1278 logging.error(u"No data.")
1281 # Prepare the data for the plot
1286 if y_vals.get(test[u"name"], None) is None:
1287 y_vals[test[u"name"]] = list()
1289 y_vals[test[u"name"]].append(test[u"result"])
1290 except (KeyError, TypeError):
1291 y_vals[test[u"name"]].append(None)
1293 # Add None to the lists with missing data
1295 nr_of_samples = list()
1296 for val in y_vals.values():
1297 if len(val) > max_len:
1299 nr_of_samples.append(len(val))
1300 for val in y_vals.values():
1301 if len(val) < max_len:
1302 val.extend([None for _ in range(max_len - len(val))])
1306 df_y = pd.DataFrame(y_vals)
1308 for i, col in enumerate(df_y.columns):
1311 f"({nr_of_samples[i]:02d} " \
1312 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1313 f"{col.lower().replace(u'-ndrpdr', u'')}"
1315 name_lst = name.split(u'-')
1318 for segment in name_lst:
1319 if (len(name) + len(segment) + 1) > 50 and split_name:
1322 name += segment + u'-'
1325 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1331 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1335 f" Writing file {plot[u'output-file']}"
1336 f"{plot[u'output-file-type']}."
1342 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1344 except PlotlyError as err:
1346 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1351 def plot_nf_heatmap(plot, input_data):
1352 """Generate the plot(s) with algorithm: plot_nf_heatmap
1353 specified in the specification file.
1355 :param plot: Plot to generate.
1356 :param input_data: Data to process.
1357 :type plot: pandas.Series
1358 :type input_data: InputData
1361 def sort_by_int(value):
1362 """Makes possible to sort a list of strings which represent integers.
1364 :param value: Integer as a string.
1366 :returns: Integer representation of input parameter 'value'.
1371 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1372 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1374 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1377 # Transform the data
1379 f" Creating the data set for the {plot.get(u'type', u'')} "
1380 f"{plot.get(u'title', u'')}."
1382 in_data = input_data.filter_tests_by_name(
1384 continue_on_error=True,
1385 params=[u"throughput", u"result", u"name", u"tags", u"type"]
1387 if in_data is None or in_data.empty:
1388 logging.error(u"No data.")
1391 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
1392 for core in plot.get(u"core", tuple()):
1393 for item in plot.get(u"include", tuple()):
1394 reg_ex = re.compile(str(item.format(core=core)).lower())
1397 for test_id, test in build.iteritems():
1398 if not re.match(reg_ex, str(test_id).lower()):
1400 for tag in test[u"tags"]:
1401 groups = re.search(regex_cn, tag)
1403 chain = str(groups.group(1))
1404 node = str(groups.group(2))
1408 groups = re.search(regex_test_name, test[u"name"])
1409 if groups and len(groups.groups()) == 3:
1411 f"{str(groups.group(1))}-"
1412 f"{str(groups.group(2))}-"
1413 f"{str(groups.group(3))}"
1417 if vals.get(chain, None) is None:
1418 vals[chain] = dict()
1419 if vals[chain].get(node, None) is None:
1420 vals[chain][node] = dict(
1429 result = test[u"result"][u"receive-rate"]
1430 elif ttype == u"pdr":
1432 test[u"throughput"][u"PDR"][u"LOWER"]
1433 elif ttype == u"ndr":
1435 test[u"throughput"][u"NDR"][u"LOWER"]
1442 vals[chain][node][u"vals"].append(result)
1445 logging.error(u"No data.")
1451 txt_chains.append(key_c)
1452 for key_n in vals[key_c].keys():
1453 txt_nodes.append(key_n)
1454 if vals[key_c][key_n][u"vals"]:
1455 vals[key_c][key_n][u"nr"] = \
1456 len(vals[key_c][key_n][u"vals"])
1457 vals[key_c][key_n][u"mean"] = \
1458 round(mean(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1459 vals[key_c][key_n][u"stdev"] = \
1460 round(stdev(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1461 txt_nodes = list(set(txt_nodes))
1463 txt_chains = sorted(txt_chains, key=sort_by_int)
1464 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1466 chains = [i + 1 for i in range(len(txt_chains))]
1467 nodes = [i + 1 for i in range(len(txt_nodes))]
1469 data = [list() for _ in range(len(chains))]
1470 for chain in chains:
1473 val = vals[txt_chains[chain - 1]] \
1474 [txt_nodes[node - 1]][u"mean"]
1475 except (KeyError, IndexError):
1477 data[chain - 1].append(val)
1480 my_green = [[0.0, u"rgb(235, 249, 242)"],
1481 [1.0, u"rgb(45, 134, 89)"]]
1483 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1484 [1.0, u"rgb(57, 115, 172)"]]
1486 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1487 [1.0, u"rgb(102, 102, 102)"]]
1490 annotations = list()
1492 text = (u"Test: {name}<br>"
1497 for chain, _ in enumerate(txt_chains):
1499 for node, _ in enumerate(txt_nodes):
1500 if data[chain][node] is not None:
1509 text=str(data[chain][node]),
1517 hover_line.append(text.format(
1518 name=vals[txt_chains[chain]][txt_nodes[node]]
1520 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1521 val=data[chain][node],
1522 stdev=vals[txt_chains[chain]][txt_nodes[node]]
1525 hovertext.append(hover_line)
1533 title=plot.get(u"z-axis", u"{test_type}").
1534 format(test_type=ttype.upper()),
1548 colorscale=my_green,
1554 for idx, item in enumerate(txt_nodes):
1572 for idx, item in enumerate(txt_chains):
1599 text=plot.get(u"x-axis", u""),
1616 text=plot.get(u"y-axis", u""),
1625 updatemenus = list([
1636 u"colorscale": [my_green, ],
1637 u"reversescale": False
1646 u"colorscale": [my_blue, ],
1647 u"reversescale": False
1656 u"colorscale": [my_grey, ],
1657 u"reversescale": False
1668 layout = deepcopy(plot[u"layout"])
1669 except KeyError as err:
1671 f"Finished with error: No layout defined\n{repr(err)}"
1675 layout[u"annotations"] = annotations
1676 layout[u'updatemenus'] = updatemenus
1677 if layout.get(u"title", None):
1678 layout[u"title"] = layout[u'title'].replace(u"test_type", ttype)
1682 plpl = plgo.Figure(data=traces, layout=layout)
1686 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
1689 logging.info(f" Writing file {file_name}")
1696 except PlotlyError as err:
1698 f" Finished with error: {repr(err)}".replace(u"\n", u" ")