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"
609 elif test[u"type"] in (u"LDP_NGINX",):
610 if u"TCP_CPS" in test[u"tags"]:
611 test_type = u"VSAP_CPS"
612 y_vals[test[u"parent"]].append(
613 test[u"result"][u"cps"] / 1e6
615 elif u"TCP_RPS" in test[u"tags"]:
616 test_type = u"VSAP_RPS"
617 y_vals[test[u"parent"]].append(
618 test[u"result"][u"rps"] / 1e6
625 except (KeyError, TypeError):
626 y_vals[test[u"parent"]].append(None)
628 # Add None to the lists with missing data
630 nr_of_samples = list()
631 for val in y_vals.values():
632 if len(val) > max_len:
634 nr_of_samples.append(len(val))
635 for val in y_vals.values():
636 if len(val) < max_len:
637 val.extend([None for _ in range(max_len - len(val))])
641 df_y = pd.DataFrame(y_vals)
644 for i, col in enumerate(df_y.columns):
645 tst_name = re.sub(REGEX_NIC, u"",
646 col.lower().replace(u'-ndrpdr', u'').
647 replace(u'2n1l-', u''))
649 x=[str(i + 1) + u'.'] * len(df_y[col]),
650 y=[y / 1e6 if y else None for y in df_y[col]],
653 f"({nr_of_samples[i]:02d} "
654 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
659 if test_type in (u"SOAK", ):
660 kwargs[u"boxpoints"] = u"all"
662 traces.append(plgo.Box(**kwargs))
665 val_max = max(df_y[col])
667 y_max.append(int(val_max / 1e6))
668 except (ValueError, TypeError) as err:
669 logging.error(repr(err))
674 layout = deepcopy(plot[u"layout"])
675 if layout.get(u"title", None):
676 if test_type in (u"HOSTSTACK", ):
677 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
678 elif test_type == u"VSAP_CPS":
679 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
680 layout[u"yaxis"][u"title"] = u"<b>Connection Rate [Mcps]</b>"
681 elif test_type == u"VSAP_RPS":
682 layout[u"title"] = f"<b>RPS:</b> {layout[u'title']}"
683 layout[u"yaxis"][u"title"] = u"<b>Connection Rate [Mrps]</b>"
685 layout[u"title"] = f"<b>Tput:</b> {layout[u'title']}"
686 if y_max and max(y_max) > 1:
687 layout[u"yaxis"][u"range"] = [0, max(y_max) + 2]
688 plpl = plgo.Figure(data=traces, layout=layout)
691 logging.info(f" Writing file {plot[u'output-file']}.html.")
696 filename=f"{plot[u'output-file']}.html"
698 except PlotlyError as err:
700 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
705 def plot_ndrpdr_box_name(plot, input_data):
706 """Generate the plot(s) with algorithm: plot_ndrpdr_box_name
707 specified in the specification file.
709 :param plot: Plot to generate.
710 :param input_data: Data to process.
711 :type plot: pandas.Series
712 :type input_data: InputData
717 f" Creating data set for the {plot.get(u'type', u'')} "
718 f"{plot.get(u'title', u'')}."
720 data = input_data.filter_tests_by_name(
722 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
725 logging.error(u"No data.")
728 if u"-gbps" in plot.get(u"title", u"").lower():
732 value = u"throughput"
737 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
738 for core in plot.get(u"core", tuple()):
739 # Prepare the data for the plot
741 data_y = OrderedDict()
744 for item in plot.get(u"include", tuple()):
745 reg_ex = re.compile(str(item.format(core=core)).lower())
748 for test_id, test in build.iteritems():
749 if not re.match(reg_ex, str(test_id).lower()):
751 if data_y.get(test[u"parent"], None) is None:
752 data_y[test[u"parent"]] = list()
753 test_type = test[u"type"]
757 data_y[test[u"parent"]].append(
758 test[value][ttype.upper()][u"LOWER"] *
761 except (KeyError, TypeError):
766 for idx, (key, vals) in enumerate(data_y.items()):
768 REGEX_NIC, u'', key.lower().replace(u'-ndrpdr', u'').
769 replace(u'2n1l-', u'')
773 x=[data_x[idx], ] * len(data_x),
774 y=[y / 1e6 if y else None for y in vals],
779 f"{u's' if len(vals) > 1 else u''}) "
786 data_y_max.append(max(vals))
787 except ValueError as err:
788 logging.warning(f"No values to use.\n{err!r}")
791 layout = deepcopy(plot[u"layout"])
792 if layout.get(u"title", None):
794 layout[u'title'].format(core=core, test_type=ttype)
795 if test_type in (u"CPS", ):
796 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
799 f"<b>Tput:</b> {layout[u'title']}"
801 layout[u"yaxis"][u"range"] = [0, max(data_y_max) / 1e6 + 1]
802 plpl = plgo.Figure(data=traces, layout=layout)
806 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
809 logging.info(f" Writing file {file_name}")
816 except PlotlyError as err:
818 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
822 def plot_mrr_box_name(plot, input_data):
823 """Generate the plot(s) with algorithm: plot_mrr_box_name
824 specified in the specification file.
826 :param plot: Plot to generate.
827 :param input_data: Data to process.
828 :type plot: pandas.Series
829 :type input_data: InputData
834 f" Creating data set for the {plot.get(u'type', u'')} "
835 f"{plot.get(u'title', u'')}."
837 data = input_data.filter_tests_by_name(
839 params=[u"result", u"parent", u"tags", u"type"]
842 logging.error(u"No data.")
845 for core in plot.get(u"core", tuple()):
846 # Prepare the data for the plot
852 for item in plot.get(u"include", tuple()):
853 reg_ex = re.compile(str(item.format(core=core)).lower())
856 for test_id, test in build.iteritems():
857 if not re.match(reg_ex, str(test_id).lower()):
862 REGEX_NIC, u'', test[u'parent'].lower().
863 replace(u'-mrr', u'').replace(u'2n1l-', u'')
865 data_y.append(test[u"result"][u"samples"])
868 f"({len(data_y[-1]):02d} "
869 f"run{u's' if len(data_y[-1]) > 1 else u''}) "
872 data_y_max.append(max(data_y[-1]))
874 except (KeyError, TypeError):
879 for idx, x_item in enumerate(data_x):
882 x=[x_item, ] * len(data_y[idx]),
884 name=data_names[idx],
891 layout = deepcopy(plot[u"layout"])
892 if layout.get(u"title", None):
894 f"<b>Tput:</b> {layout[u'title'].format(core=core)}"
897 layout[u"yaxis"][u"range"] = [0, max(data_y_max) + 1]
898 plpl = plgo.Figure(data=traces, layout=layout)
901 file_name = f"{plot[u'output-file'].format(core=core)}.html"
902 logging.info(f" Writing file {file_name}")
909 except PlotlyError as err:
911 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
915 def plot_tsa_name(plot, input_data):
916 """Generate the plot(s) with algorithm:
918 specified in the specification file.
920 :param plot: Plot to generate.
921 :param input_data: Data to process.
922 :type plot: pandas.Series
923 :type input_data: InputData
927 plot_title = plot.get(u"title", u"")
929 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
931 data = input_data.filter_tests_by_name(
933 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
936 logging.error(u"No data.")
939 plot_title = plot_title.lower()
941 if u"-gbps" in plot_title:
946 value = u"throughput"
950 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
951 y_vals = OrderedDict()
952 for item in plot.get(u"include", tuple()):
953 reg_ex = re.compile(str(item).lower())
956 for test_id, test in build.iteritems():
957 if re.match(reg_ex, str(test_id).lower()):
958 if y_vals.get(test[u"parent"], None) is None:
959 y_vals[test[u"parent"]] = {
965 if test[u"type"] not in (u"NDRPDR", u"CPS"):
968 if u"1C" in test[u"tags"]:
969 y_vals[test[u"parent"]][u"1"].append(
970 test[value][ttype.upper()][u"LOWER"] *
973 elif u"2C" in test[u"tags"]:
974 y_vals[test[u"parent"]][u"2"].append(
975 test[value][ttype.upper()][u"LOWER"] *
978 elif u"4C" in test[u"tags"]:
979 y_vals[test[u"parent"]][u"4"].append(
980 test[value][ttype.upper()][u"LOWER"] *
983 except (KeyError, TypeError):
987 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
991 for test_name, test_vals in y_vals.items():
992 for key, test_val in test_vals.items():
994 avg_val = sum(test_val) / len(test_val)
995 y_vals[test_name][key] = [avg_val, len(test_val)]
996 ideal = avg_val / (int(key) * 1e6)
997 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
998 y_1c_max[test_name] = ideal
1000 vals = OrderedDict()
1005 for test_name, test_vals in y_vals.items():
1007 if test_vals[u"1"][1]:
1011 test_name.replace(u'-ndrpdr', u'').
1012 replace(u'2n1l-', u'')
1014 vals[name] = OrderedDict()
1015 y_val_1 = test_vals[u"1"][0] / 1e6
1016 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
1018 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
1021 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
1022 vals[name][u"rel"] = [1.0, None, None]
1023 vals[name][u"ideal"] = [
1024 y_1c_max[test_name],
1025 y_1c_max[test_name] * 2,
1026 y_1c_max[test_name] * 4
1028 vals[name][u"diff"] = [
1029 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1,
1033 vals[name][u"count"] = [
1040 val_max = max(vals[name][u"val"])
1041 except ValueError as err:
1042 logging.error(repr(err))
1045 y_max.append(val_max)
1048 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
1049 vals[name][u"diff"][1] = \
1050 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
1052 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
1053 vals[name][u"diff"][2] = \
1054 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
1055 except IndexError as err:
1056 logging.warning(f"No data for {test_name}")
1057 logging.warning(repr(err))
1060 if u"x520" in test_name:
1061 limit = plot[u"limits"][u"nic"][u"x520"]
1062 elif u"x710" in test_name:
1063 limit = plot[u"limits"][u"nic"][u"x710"]
1064 elif u"xxv710" in test_name:
1065 limit = plot[u"limits"][u"nic"][u"xxv710"]
1066 elif u"xl710" in test_name:
1067 limit = plot[u"limits"][u"nic"][u"xl710"]
1068 elif u"x553" in test_name:
1069 limit = plot[u"limits"][u"nic"][u"x553"]
1070 elif u"cx556a" in test_name:
1071 limit = plot[u"limits"][u"nic"][u"cx556a"]
1072 elif u"e810cq" in test_name:
1073 limit = plot[u"limits"][u"nic"][u"e810cq"]
1076 if limit > nic_limit:
1079 mul = 2 if u"ge2p" in test_name else 1
1080 if u"10ge" in test_name:
1081 limit = plot[u"limits"][u"link"][u"10ge"] * mul
1082 elif u"25ge" in test_name:
1083 limit = plot[u"limits"][u"link"][u"25ge"] * mul
1084 elif u"40ge" in test_name:
1085 limit = plot[u"limits"][u"link"][u"40ge"] * mul
1086 elif u"100ge" in test_name:
1087 limit = plot[u"limits"][u"link"][u"100ge"] * mul
1090 if limit > lnk_limit:
1093 if u"cx556a" in test_name:
1094 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
1096 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
1097 if limit > pci_limit:
1101 annotations = list()
1105 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
1109 min_limit = min((nic_limit, lnk_limit, pci_limit))
1110 if nic_limit == min_limit:
1111 traces.append(plgo.Scatter(
1113 y=[nic_limit, ] * len(x_vals),
1114 name=f"NIC: {nic_limit:.2f}Mpps",
1123 annotations.append(dict(
1130 text=f"NIC: {nic_limit:.2f}Mpps",
1138 y_max.append(nic_limit)
1139 elif lnk_limit == min_limit:
1140 traces.append(plgo.Scatter(
1142 y=[lnk_limit, ] * len(x_vals),
1143 name=f"Link: {lnk_limit:.2f}Mpps",
1152 annotations.append(dict(
1159 text=f"Link: {lnk_limit:.2f}Mpps",
1167 y_max.append(lnk_limit)
1168 elif pci_limit == min_limit:
1169 traces.append(plgo.Scatter(
1171 y=[pci_limit, ] * len(x_vals),
1172 name=f"PCIe: {pci_limit:.2f}Mpps",
1181 annotations.append(dict(
1188 text=f"PCIe: {pci_limit:.2f}Mpps",
1196 y_max.append(pci_limit)
1198 # Perfect and measured:
1200 for name, val in vals.items():
1203 for idx in range(len(val[u"val"])):
1205 if isinstance(val[u"val"][idx], float):
1207 f"No. of Runs: {val[u'count'][idx]}<br>"
1208 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
1210 if isinstance(val[u"diff"][idx], float):
1211 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
1212 if isinstance(val[u"rel"][idx], float):
1213 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
1214 hovertext.append(htext)
1221 mode=u"lines+markers",
1230 hoverinfo=u"text+name"
1237 name=f"{name} perfect",
1245 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1250 except (IndexError, ValueError, KeyError) as err:
1251 logging.warning(f"No data for {name}\n{repr(err)}")
1255 file_name = f"{plot[u'output-file'].format(test_type=ttype)}.html"
1256 logging.info(f" Writing file {file_name}")
1257 layout = deepcopy(plot[u"layout"])
1258 if layout.get(u"title", None):
1259 layout[u"title"] = (
1260 f"<b>Speedup Multi-core:</b> "
1261 f"{layout[u'title'].format(test_type=ttype)}"
1263 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1264 layout[u"annotations"].extend(annotations)
1265 plpl = plgo.Figure(data=traces, layout=layout)
1274 except PlotlyError as err:
1276 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1280 def plot_http_server_perf_box(plot, input_data):
1281 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1282 specified in the specification file.
1284 :param plot: Plot to generate.
1285 :param input_data: Data to process.
1286 :type plot: pandas.Series
1287 :type input_data: InputData
1290 # Transform the data
1292 f" Creating the data set for the {plot.get(u'type', u'')} "
1293 f"{plot.get(u'title', u'')}."
1295 data = input_data.filter_data(plot)
1297 logging.error(u"No data.")
1300 # Prepare the data for the plot
1305 if y_vals.get(test[u"name"], None) is None:
1306 y_vals[test[u"name"]] = list()
1308 y_vals[test[u"name"]].append(test[u"result"])
1309 except (KeyError, TypeError):
1310 y_vals[test[u"name"]].append(None)
1312 # Add None to the lists with missing data
1314 nr_of_samples = list()
1315 for val in y_vals.values():
1316 if len(val) > max_len:
1318 nr_of_samples.append(len(val))
1319 for val in y_vals.values():
1320 if len(val) < max_len:
1321 val.extend([None for _ in range(max_len - len(val))])
1325 df_y = pd.DataFrame(y_vals)
1327 for i, col in enumerate(df_y.columns):
1330 f"({nr_of_samples[i]:02d} " \
1331 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1332 f"{col.lower().replace(u'-ndrpdr', u'')}"
1334 name_lst = name.split(u'-')
1337 for segment in name_lst:
1338 if (len(name) + len(segment) + 1) > 50 and split_name:
1341 name += segment + u'-'
1344 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1350 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1354 f" Writing file {plot[u'output-file']}"
1355 f"{plot[u'output-file-type']}."
1361 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1363 except PlotlyError as err:
1365 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1370 def plot_nf_heatmap(plot, input_data):
1371 """Generate the plot(s) with algorithm: plot_nf_heatmap
1372 specified in the specification file.
1374 :param plot: Plot to generate.
1375 :param input_data: Data to process.
1376 :type plot: pandas.Series
1377 :type input_data: InputData
1380 def sort_by_int(value):
1381 """Makes possible to sort a list of strings which represent integers.
1383 :param value: Integer as a string.
1385 :returns: Integer representation of input parameter 'value'.
1390 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1391 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1393 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1396 # Transform the data
1398 f" Creating the data set for the {plot.get(u'type', u'')} "
1399 f"{plot.get(u'title', u'')}."
1401 in_data = input_data.filter_tests_by_name(
1403 continue_on_error=True,
1404 params=[u"throughput", u"result", u"name", u"tags", u"type"]
1406 if in_data is None or in_data.empty:
1407 logging.error(u"No data.")
1410 for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
1411 for core in plot.get(u"core", tuple()):
1412 for item in plot.get(u"include", tuple()):
1413 reg_ex = re.compile(str(item.format(core=core)).lower())
1416 for test_id, test in build.iteritems():
1417 if not re.match(reg_ex, str(test_id).lower()):
1419 for tag in test[u"tags"]:
1420 groups = re.search(regex_cn, tag)
1422 chain = str(groups.group(1))
1423 node = str(groups.group(2))
1427 groups = re.search(regex_test_name, test[u"name"])
1428 if groups and len(groups.groups()) == 3:
1430 f"{str(groups.group(1))}-"
1431 f"{str(groups.group(2))}-"
1432 f"{str(groups.group(3))}"
1436 if vals.get(chain, None) is None:
1437 vals[chain] = dict()
1438 if vals[chain].get(node, None) is None:
1439 vals[chain][node] = dict(
1448 result = test[u"result"][u"receive-rate"]
1449 elif ttype == u"pdr":
1451 test[u"throughput"][u"PDR"][u"LOWER"]
1452 elif ttype == u"ndr":
1454 test[u"throughput"][u"NDR"][u"LOWER"]
1461 vals[chain][node][u"vals"].append(result)
1464 logging.error(u"No data.")
1470 txt_chains.append(key_c)
1471 for key_n in vals[key_c].keys():
1472 txt_nodes.append(key_n)
1473 if vals[key_c][key_n][u"vals"]:
1474 vals[key_c][key_n][u"nr"] = \
1475 len(vals[key_c][key_n][u"vals"])
1476 vals[key_c][key_n][u"mean"] = \
1477 round(mean(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1478 vals[key_c][key_n][u"stdev"] = \
1479 round(stdev(vals[key_c][key_n][u"vals"]) / 1e6, 1)
1480 txt_nodes = list(set(txt_nodes))
1482 txt_chains = sorted(txt_chains, key=sort_by_int)
1483 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1485 chains = [i + 1 for i in range(len(txt_chains))]
1486 nodes = [i + 1 for i in range(len(txt_nodes))]
1488 data = [list() for _ in range(len(chains))]
1489 for chain in chains:
1492 val = vals[txt_chains[chain - 1]] \
1493 [txt_nodes[node - 1]][u"mean"]
1494 except (KeyError, IndexError):
1496 data[chain - 1].append(val)
1499 my_green = [[0.0, u"rgb(235, 249, 242)"],
1500 [1.0, u"rgb(45, 134, 89)"]]
1502 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1503 [1.0, u"rgb(57, 115, 172)"]]
1505 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1506 [1.0, u"rgb(102, 102, 102)"]]
1509 annotations = list()
1511 text = (u"Test: {name}<br>"
1516 for chain, _ in enumerate(txt_chains):
1518 for node, _ in enumerate(txt_nodes):
1519 if data[chain][node] is not None:
1528 text=str(data[chain][node]),
1536 hover_line.append(text.format(
1537 name=vals[txt_chains[chain]][txt_nodes[node]]
1539 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1540 val=data[chain][node],
1541 stdev=vals[txt_chains[chain]][txt_nodes[node]]
1544 hovertext.append(hover_line)
1552 title=plot.get(u"z-axis", u"{test_type}").
1553 format(test_type=ttype.upper()),
1567 colorscale=my_green,
1573 for idx, item in enumerate(txt_nodes):
1591 for idx, item in enumerate(txt_chains):
1618 text=plot.get(u"x-axis", u""),
1635 text=plot.get(u"y-axis", u""),
1644 updatemenus = list([
1655 u"colorscale": [my_green, ],
1656 u"reversescale": False
1665 u"colorscale": [my_blue, ],
1666 u"reversescale": False
1675 u"colorscale": [my_grey, ],
1676 u"reversescale": False
1687 layout = deepcopy(plot[u"layout"])
1688 except KeyError as err:
1690 f"Finished with error: No layout defined\n{repr(err)}"
1694 layout[u"annotations"] = annotations
1695 layout[u'updatemenus'] = updatemenus
1696 if layout.get(u"title", None):
1697 layout[u"title"] = layout[u'title'].replace(u"test_type", ttype)
1701 plpl = plgo.Figure(data=traces, layout=layout)
1705 f"{plot[u'output-file'].format(core=core, test_type=ttype)}"
1708 logging.info(f" Writing file {file_name}")
1715 except PlotlyError as err:
1717 f" Finished with error: {repr(err)}".replace(u"\n", u" ")