1 # Copyright (c) 2021 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Algorithms to generate plots.
24 import plotly.offline as ploff
25 import plotly.graph_objs as plgo
27 from collections import OrderedDict
28 from copy import deepcopy
31 from plotly.exceptions import PlotlyError
33 from pal_utils import mean, stdev
62 REGEX_NIC = re.compile(r'(\d*ge\dp\d\D*\d*[a-z]*)-')
64 # This value depends on latency stream rate (9001 pps) and duration (5s).
65 # Keep it slightly higher to ensure rounding errors to not remove tick mark.
66 PERCENTILE_MAX = 99.999501
69 def generate_plots(spec, data):
70 """Generate all plots specified in the specification file.
72 :param spec: Specification read from the specification file.
73 :param data: Data to process.
74 :type spec: Specification
79 u"plot_nf_reconf_box_name": plot_nf_reconf_box_name,
80 u"plot_perf_box_name": plot_perf_box_name,
81 u"plot_tsa_name": plot_tsa_name,
82 u"plot_http_server_perf_box": plot_http_server_perf_box,
83 u"plot_nf_heatmap": plot_nf_heatmap,
84 u"plot_hdrh_lat_by_percentile": plot_hdrh_lat_by_percentile,
85 u"plot_hdrh_lat_by_percentile_x_log": plot_hdrh_lat_by_percentile_x_log,
86 u"plot_mrr_error_bars_name": plot_mrr_error_bars_name
89 logging.info(u"Generating the plots ...")
90 for index, plot in enumerate(spec.plots):
92 logging.info(f" Plot nr {index + 1}: {plot.get(u'title', u'')}")
93 plot[u"limits"] = spec.configuration[u"limits"]
94 generator[plot[u"algorithm"]](plot, data)
95 logging.info(u" Done.")
96 except NameError as err:
98 f"Probably algorithm {plot[u'algorithm']} is not defined: "
101 logging.info(u"Done.")
104 def plot_hdrh_lat_by_percentile(plot, input_data):
105 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile
106 specified in the specification file.
108 :param plot: Plot to generate.
109 :param input_data: Data to process.
110 :type plot: pandas.Series
111 :type input_data: InputData
116 f" Creating the data set for the {plot.get(u'type', u'')} "
117 f"{plot.get(u'title', u'')}."
119 if plot.get(u"include", None):
120 data = input_data.filter_tests_by_name(
122 params=[u"name", u"latency", u"parent", u"tags", u"type"]
124 elif plot.get(u"filter", None):
125 data = input_data.filter_data(
127 params=[u"name", u"latency", u"parent", u"tags", u"type"],
128 continue_on_error=True
131 job = list(plot[u"data"].keys())[0]
132 build = str(plot[u"data"][job][0])
133 data = input_data.tests(job, build)
135 if data is None or len(data) == 0:
136 logging.error(u"No data.")
140 u"LAT0": u"No-load.",
141 u"PDR10": u"Low-load, 10% PDR.",
142 u"PDR50": u"Mid-load, 50% PDR.",
143 u"PDR90": u"High-load, 90% PDR.",
144 u"PDR": u"Full-load, 100% PDR.",
145 u"NDR10": u"Low-load, 10% NDR.",
146 u"NDR50": u"Mid-load, 50% NDR.",
147 u"NDR90": u"High-load, 90% NDR.",
148 u"NDR": u"Full-load, 100% NDR."
158 file_links = plot.get(u"output-file-links", None)
159 target_links = plot.get(u"target-links", None)
163 if test[u"type"] not in (u"NDRPDR",):
164 logging.warning(f"Invalid test type: {test[u'type']}")
166 name = re.sub(REGEX_NIC, u"", test[u"parent"].
167 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
169 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
170 except (IndexError, AttributeError, KeyError, ValueError):
172 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
174 logging.info(f" Generating the graph: {name_link}")
177 layout = deepcopy(plot[u"layout"])
179 for color, graph in enumerate(graphs):
180 for idx, direction in enumerate((u"direction1", u"direction2")):
186 decoded = hdrh.histogram.HdrHistogram.decode(
187 test[u"latency"][graph][direction][u"hdrh"]
189 except hdrh.codec.HdrLengthException:
191 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
195 for item in decoded.get_recorded_iterator():
196 percentile = item.percentile_level_iterated_to
197 xaxis.append(previous_x)
198 yaxis.append(item.value_iterated_to)
200 f"<b>{desc[graph]}</b><br>"
201 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
202 f"Percentile: {previous_x:.5f}-{percentile:.5f}%<br>"
203 f"Latency: {item.value_iterated_to}uSec"
205 xaxis.append(percentile)
206 yaxis.append(item.value_iterated_to)
208 f"<b>{desc[graph]}</b><br>"
209 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
210 f"Percentile: {previous_x:.5f}-{percentile:.5f}%<br>"
211 f"Latency: {item.value_iterated_to}uSec"
213 previous_x = percentile
220 legendgroup=desc[graph],
221 showlegend=bool(idx),
225 width=1 if idx % 2 else 2
232 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
233 fig.update_layout(layout)
236 file_name = f"{plot[u'output-file']}-{name_link}.html"
237 logging.info(f" Writing file {file_name}")
241 ploff.plot(fig, show_link=False, auto_open=False,
243 # Add link to the file:
244 if file_links and target_links:
245 with open(file_links, u"a") as file_handler:
248 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
250 except FileNotFoundError as err:
252 f"Not possible to write the link to the file "
253 f"{file_links}\n{err}"
255 except PlotlyError as err:
256 logging.error(f" Finished with error: {repr(err)}")
258 except hdrh.codec.HdrLengthException as err:
259 logging.warning(repr(err))
262 except (ValueError, KeyError) as err:
263 logging.warning(repr(err))
267 def plot_hdrh_lat_by_percentile_x_log(plot, input_data):
268 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile_x_log
269 specified in the specification file.
271 :param plot: Plot to generate.
272 :param input_data: Data to process.
273 :type plot: pandas.Series
274 :type input_data: InputData
279 f" Creating the data set for the {plot.get(u'type', u'')} "
280 f"{plot.get(u'title', u'')}."
282 if plot.get(u"include", None):
283 data = input_data.filter_tests_by_name(
285 params=[u"name", u"latency", u"parent", u"tags", u"type"]
287 elif plot.get(u"filter", None):
288 data = input_data.filter_data(
290 params=[u"name", u"latency", u"parent", u"tags", u"type"],
291 continue_on_error=True
294 job = list(plot[u"data"].keys())[0]
295 build = str(plot[u"data"][job][0])
296 data = input_data.tests(job, build)
298 if data is None or len(data) == 0:
299 logging.error(u"No data.")
303 u"LAT0": u"No-load.",
304 u"PDR10": u"Low-load, 10% PDR.",
305 u"PDR50": u"Mid-load, 50% PDR.",
306 u"PDR90": u"High-load, 90% PDR.",
307 u"PDR": u"Full-load, 100% PDR.",
308 u"NDR10": u"Low-load, 10% NDR.",
309 u"NDR50": u"Mid-load, 50% NDR.",
310 u"NDR90": u"High-load, 90% NDR.",
311 u"NDR": u"Full-load, 100% NDR."
321 file_links = plot.get(u"output-file-links", None)
322 target_links = plot.get(u"target-links", None)
326 if test[u"type"] not in (u"NDRPDR",):
327 logging.warning(f"Invalid test type: {test[u'type']}")
329 name = re.sub(REGEX_NIC, u"", test[u"parent"].
330 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
332 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
333 except (IndexError, AttributeError, KeyError, ValueError):
335 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
337 logging.info(f" Generating the graph: {name_link}")
340 layout = deepcopy(plot[u"layout"])
342 for color, graph in enumerate(graphs):
343 for idx, direction in enumerate((u"direction1", u"direction2")):
350 decoded = hdrh.histogram.HdrHistogram.decode(
351 test[u"latency"][graph][direction][u"hdrh"]
353 except hdrh.codec.HdrLengthException:
355 f"No data for direction {(u'W-E', u'E-W')[idx % 2]}"
359 for item in decoded.get_recorded_iterator():
360 # The real value is "percentile".
361 # For 100%, we cut that down to "x_perc" to avoid
363 percentile = item.percentile_level_iterated_to
364 x_perc = min(percentile, PERCENTILE_MAX)
365 xaxis.append(previous_x)
366 yaxis.append(item.value_iterated_to)
368 f"<b>{desc[graph]}</b><br>"
369 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
370 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
371 f"Latency: {item.value_iterated_to}uSec"
373 next_x = 100.0 / (100.0 - x_perc)
375 yaxis.append(item.value_iterated_to)
377 f"<b>{desc[graph]}</b><br>"
378 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
379 f"Percentile: {prev_perc:.5f}-{percentile:.5f}%<br>"
380 f"Latency: {item.value_iterated_to}uSec"
383 prev_perc = percentile
390 legendgroup=desc[graph],
391 showlegend=not(bool(idx)),
395 width=1 if idx % 2 else 2
402 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
403 x_max = log(100.0 / (100.0 - PERCENTILE_MAX), 10)
404 layout[u"xaxis"][u"range"] = [0, x_max]
405 fig.update_layout(layout)
408 file_name = f"{plot[u'output-file']}-{name_link}.html"
409 logging.info(f" Writing file {file_name}")
413 ploff.plot(fig, show_link=False, auto_open=False,
415 # Add link to the file:
416 if file_links and target_links:
417 with open(file_links, u"a") as file_handler:
420 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
422 except FileNotFoundError as err:
424 f"Not possible to write the link to the file "
425 f"{file_links}\n{err}"
427 except PlotlyError as err:
428 logging.error(f" Finished with error: {repr(err)}")
430 except hdrh.codec.HdrLengthException as err:
431 logging.warning(repr(err))
434 except (ValueError, KeyError) as err:
435 logging.warning(repr(err))
439 def plot_nf_reconf_box_name(plot, input_data):
440 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
441 specified in the specification file.
443 :param plot: Plot to generate.
444 :param input_data: Data to process.
445 :type plot: pandas.Series
446 :type input_data: InputData
451 f" Creating the data set for the {plot.get(u'type', u'')} "
452 f"{plot.get(u'title', u'')}."
454 data = input_data.filter_tests_by_name(
455 plot, params=[u"result", u"parent", u"tags", u"type"]
458 logging.error(u"No data.")
461 # Prepare the data for the plot
462 y_vals = OrderedDict()
467 if y_vals.get(test[u"parent"], None) is None:
468 y_vals[test[u"parent"]] = list()
469 loss[test[u"parent"]] = list()
471 y_vals[test[u"parent"]].append(test[u"result"][u"time"])
472 loss[test[u"parent"]].append(test[u"result"][u"loss"])
473 except (KeyError, TypeError):
474 y_vals[test[u"parent"]].append(None)
476 # Add None to the lists with missing data
478 nr_of_samples = list()
479 for val in y_vals.values():
480 if len(val) > max_len:
482 nr_of_samples.append(len(val))
483 for val in y_vals.values():
484 if len(val) < max_len:
485 val.extend([None for _ in range(max_len - len(val))])
489 df_y = pd.DataFrame(y_vals)
491 for i, col in enumerate(df_y.columns):
493 tst_name = re.sub(REGEX_NIC, u"",
494 col.lower().replace(u'-reconf', u'').
495 replace(u'2n1l-', u'').replace(u'2n-', u'').
496 replace(u'-testpmd', u''))
498 traces.append(plgo.Box(
499 x=[str(i + 1) + u'.'] * len(df_y[col]),
503 f"({nr_of_samples[i]:02d} "
504 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
505 f"packets lost average: {mean(loss[col]):.1f}) "
506 f"{u'-'.join(tst_name.split(u'-')[2:])}"
512 layout = deepcopy(plot[u"layout"])
513 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
514 layout[u"yaxis"][u"title"] = u"<b>Effective Blocked Time [s]</b>"
515 layout[u"legend"][u"font"][u"size"] = 14
516 layout[u"yaxis"].pop(u"range")
517 plpl = plgo.Figure(data=traces, layout=layout)
520 file_type = plot.get(u"output-file-type", u".html")
521 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
526 filename=f"{plot[u'output-file']}{file_type}"
528 except PlotlyError as err:
530 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
535 def plot_perf_box_name(plot, input_data):
536 """Generate the plot(s) with algorithm: plot_perf_box_name
537 specified in the specification file.
539 :param plot: Plot to generate.
540 :param input_data: Data to process.
541 :type plot: pandas.Series
542 :type input_data: InputData
547 f" Creating data set for the {plot.get(u'type', u'')} "
548 f"{plot.get(u'title', u'')}."
550 data = input_data.filter_tests_by_name(
552 params=[u"throughput", u"gbps", u"result", u"parent", u"tags", u"type"])
554 logging.error(u"No data.")
557 # Prepare the data for the plot
558 plot_title = plot.get(u"title", u"").lower()
560 if u"-gbps" in plot_title:
564 value = u"throughput"
566 y_vals = OrderedDict()
569 for item in plot.get(u"include", tuple()):
570 reg_ex = re.compile(str(item).lower())
573 for test_id, test in build.iteritems():
574 if not re.match(reg_ex, str(test_id).lower()):
576 if y_vals.get(test[u"parent"], None) is None:
577 y_vals[test[u"parent"]] = list()
579 if test[u"type"] in (u"NDRPDR", u"CPS"):
580 test_type = test[u"type"]
582 if u"-pdr" in plot_title:
584 elif u"-ndr" in plot_title:
588 u"Wrong title. No information about test "
589 u"type. Add '-ndr' or '-pdr' to the test "
593 y_vals[test[u"parent"]].append(
594 test[value][ttype][u"LOWER"] * multiplier
597 elif test[u"type"] in (u"SOAK",):
598 y_vals[test[u"parent"]]. \
599 append(test[u"throughput"][u"LOWER"])
602 elif test[u"type"] in (u"HOSTSTACK",):
603 if u"LDPRELOAD" in test[u"tags"]:
604 y_vals[test[u"parent"]].append(
606 test[u"result"][u"bits_per_second"]
609 elif u"VPPECHO" in test[u"tags"]:
610 y_vals[test[u"parent"]].append(
612 test[u"result"][u"client"][u"tx_data"]
615 test[u"result"][u"client"][u"time"]
618 test[u"result"][u"server"][u"time"])
621 test_type = u"HOSTSTACK"
626 except (KeyError, TypeError):
627 y_vals[test[u"parent"]].append(None)
629 # Add None to the lists with missing data
631 nr_of_samples = list()
632 for val in y_vals.values():
633 if len(val) > max_len:
635 nr_of_samples.append(len(val))
636 for val in y_vals.values():
637 if len(val) < max_len:
638 val.extend([None for _ in range(max_len - len(val))])
642 df_y = pd.DataFrame(y_vals)
645 for i, col in enumerate(df_y.columns):
646 tst_name = re.sub(REGEX_NIC, u"",
647 col.lower().replace(u'-ndrpdr', u'').
648 replace(u'2n1l-', u''))
650 x=[str(i + 1) + u'.'] * len(df_y[col]),
651 y=[y / 1e6 if y else None for y in df_y[col]],
654 f"({nr_of_samples[i]:02d} "
655 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
660 if test_type in (u"SOAK", ):
661 kwargs[u"boxpoints"] = u"all"
663 traces.append(plgo.Box(**kwargs))
666 val_max = max(df_y[col])
668 y_max.append(int(val_max / 1e6) + 2)
669 except (ValueError, TypeError) as err:
670 logging.error(repr(err))
675 layout = deepcopy(plot[u"layout"])
676 if layout.get(u"title", None):
677 if test_type in (u"HOSTSTACK", ):
678 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
679 elif test_type in (u"CPS", ):
680 layout[u"title"] = f"<b>CPS:</b> {layout[u'title']}"
682 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
684 layout[u"yaxis"][u"range"] = [0, max(y_max)]
685 plpl = plgo.Figure(data=traces, layout=layout)
688 logging.info(f" Writing file {plot[u'output-file']}.html.")
693 filename=f"{plot[u'output-file']}.html"
695 except PlotlyError as err:
697 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
702 def plot_mrr_error_bars_name(plot, input_data):
703 """Generate the plot(s) with algorithm: plot_mrr_error_bars_name
704 specified in the specification file.
706 :param plot: Plot to generate.
707 :param input_data: Data to process.
708 :type plot: pandas.Series
709 :type input_data: InputData
714 f" Creating data set for the {plot.get(u'type', u'')} "
715 f"{plot.get(u'title', u'')}."
717 data = input_data.filter_tests_by_name(
719 params=[u"result", u"parent", u"tags", u"type"])
721 logging.error(u"No data.")
724 # Prepare the data for the plot
728 data_y_stdev = list()
732 for item in plot.get(u"include", tuple()):
733 reg_ex = re.compile(str(item).lower())
736 for test_id, test in build.iteritems():
737 if not re.match(reg_ex, str(test_id).lower()):
741 name = re.sub(REGEX_NIC, u'', test[u'parent'].lower().
742 replace(u'-mrr', u'').
743 replace(u'2n1l-', u''))
744 data_names.append(f"{idx}. {name}")
746 round(test[u"result"][u"receive-rate"], 3)
749 round(test[u"result"][u"receive-stdev"], 3)
752 f"{data_names[-1]}<br>"
753 f"average [Gbps]: {data_y_avg[-1]}<br>"
754 f"stdev [Gbps]: {data_y_stdev[-1]}"
756 if data_y_avg[-1] + data_y_stdev[-1] > data_y_max:
757 data_y_max = data_y_avg[-1] + data_y_stdev[-1]
759 except (KeyError, TypeError):
764 for idx in range(len(data_x)):
768 y=[data_y_avg[idx], ],
771 array=[data_y_stdev[idx], ],
774 name=data_names[idx],
776 text=hover_info[idx],
783 layout = deepcopy(plot[u"layout"])
784 if layout.get(u"title", None):
785 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
787 layout[u"yaxis"][u"range"] = [0, int(data_y_max) + 1]
788 plpl = plgo.Figure(data=traces, layout=layout)
791 logging.info(f" Writing file {plot[u'output-file']}.html.")
796 filename=f"{plot[u'output-file']}.html"
798 except PlotlyError as err:
800 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
805 def plot_tsa_name(plot, input_data):
806 """Generate the plot(s) with algorithm:
808 specified in the specification file.
810 :param plot: Plot to generate.
811 :param input_data: Data to process.
812 :type plot: pandas.Series
813 :type input_data: InputData
817 plot_title = plot.get(u"title", u"")
819 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
821 data = input_data.filter_tests_by_name(
823 params=[u"throughput", u"gbps", u"parent", u"tags", u"type"]
826 logging.error(u"No data.")
829 plot_title = plot_title.lower()
831 if u"-gbps" in plot_title:
836 value = u"throughput"
840 y_vals = OrderedDict()
841 for item in plot.get(u"include", tuple()):
842 reg_ex = re.compile(str(item).lower())
845 for test_id, test in build.iteritems():
846 if re.match(reg_ex, str(test_id).lower()):
847 if y_vals.get(test[u"parent"], None) is None:
848 y_vals[test[u"parent"]] = {
854 if test[u"type"] not in (u"NDRPDR", u"CPS"):
857 if u"-pdr" in plot_title:
859 elif u"-ndr" in plot_title:
864 if u"1C" in test[u"tags"]:
865 y_vals[test[u"parent"]][u"1"].append(
866 test[value][ttype][u"LOWER"] * multiplier
868 elif u"2C" in test[u"tags"]:
869 y_vals[test[u"parent"]][u"2"].append(
870 test[value][ttype][u"LOWER"] * multiplier
872 elif u"4C" in test[u"tags"]:
873 y_vals[test[u"parent"]][u"4"].append(
874 test[value][ttype][u"LOWER"] * multiplier
876 except (KeyError, TypeError):
880 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
884 for test_name, test_vals in y_vals.items():
885 for key, test_val in test_vals.items():
887 avg_val = sum(test_val) / len(test_val)
888 y_vals[test_name][key] = [avg_val, len(test_val)]
889 ideal = avg_val / (int(key) * 1e6)
890 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
891 y_1c_max[test_name] = ideal
898 for test_name, test_vals in y_vals.items():
900 if test_vals[u"1"][1]:
904 test_name.replace(u'-ndrpdr', u'').replace(u'2n1l-', u'')
906 vals[name] = OrderedDict()
907 y_val_1 = test_vals[u"1"][0] / 1e6
908 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
910 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
913 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
914 vals[name][u"rel"] = [1.0, None, None]
915 vals[name][u"ideal"] = [
917 y_1c_max[test_name] * 2,
918 y_1c_max[test_name] * 4
920 vals[name][u"diff"] = [
921 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None
923 vals[name][u"count"] = [
930 val_max = max(vals[name][u"val"])
931 except ValueError as err:
932 logging.error(repr(err))
935 y_max.append(val_max)
938 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
939 vals[name][u"diff"][1] = \
940 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
942 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
943 vals[name][u"diff"][2] = \
944 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
945 except IndexError as err:
946 logging.warning(f"No data for {test_name}")
947 logging.warning(repr(err))
950 if u"x520" in test_name:
951 limit = plot[u"limits"][u"nic"][u"x520"]
952 elif u"x710" in test_name:
953 limit = plot[u"limits"][u"nic"][u"x710"]
954 elif u"xxv710" in test_name:
955 limit = plot[u"limits"][u"nic"][u"xxv710"]
956 elif u"xl710" in test_name:
957 limit = plot[u"limits"][u"nic"][u"xl710"]
958 elif u"x553" in test_name:
959 limit = plot[u"limits"][u"nic"][u"x553"]
960 elif u"cx556a" in test_name:
961 limit = plot[u"limits"][u"nic"][u"cx556a"]
964 if limit > nic_limit:
967 mul = 2 if u"ge2p" in test_name else 1
968 if u"10ge" in test_name:
969 limit = plot[u"limits"][u"link"][u"10ge"] * mul
970 elif u"25ge" in test_name:
971 limit = plot[u"limits"][u"link"][u"25ge"] * mul
972 elif u"40ge" in test_name:
973 limit = plot[u"limits"][u"link"][u"40ge"] * mul
974 elif u"100ge" in test_name:
975 limit = plot[u"limits"][u"link"][u"100ge"] * mul
978 if limit > lnk_limit:
981 if u"cx556a" in test_name:
982 limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
984 limit = plot[u"limits"][u"pci"][u"pci-g3-x16"]
985 if limit > pci_limit:
993 if u"-gbps" not in plot_title and u"-cps-" not in plot_title:
997 min_limit = min((nic_limit, lnk_limit, pci_limit))
998 if nic_limit == min_limit:
999 traces.append(plgo.Scatter(
1001 y=[nic_limit, ] * len(x_vals),
1002 name=f"NIC: {nic_limit:.2f}Mpps",
1011 annotations.append(dict(
1018 text=f"NIC: {nic_limit:.2f}Mpps",
1026 y_max.append(nic_limit)
1027 elif lnk_limit == min_limit:
1028 traces.append(plgo.Scatter(
1030 y=[lnk_limit, ] * len(x_vals),
1031 name=f"Link: {lnk_limit:.2f}Mpps",
1040 annotations.append(dict(
1047 text=f"Link: {lnk_limit:.2f}Mpps",
1055 y_max.append(lnk_limit)
1056 elif pci_limit == min_limit:
1057 traces.append(plgo.Scatter(
1059 y=[pci_limit, ] * len(x_vals),
1060 name=f"PCIe: {pci_limit:.2f}Mpps",
1069 annotations.append(dict(
1076 text=f"PCIe: {pci_limit:.2f}Mpps",
1084 y_max.append(pci_limit)
1086 # Perfect and measured:
1088 for name, val in vals.items():
1091 for idx in range(len(val[u"val"])):
1093 if isinstance(val[u"val"][idx], float):
1095 f"No. of Runs: {val[u'count'][idx]}<br>"
1096 f"Mean: {val[u'val'][idx]:.2f}{h_unit}<br>"
1098 if isinstance(val[u"diff"][idx], float):
1099 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
1100 if isinstance(val[u"rel"][idx], float):
1101 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
1102 hovertext.append(htext)
1109 mode=u"lines+markers",
1118 hoverinfo=u"text+name"
1125 name=f"{name} perfect",
1133 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
1138 except (IndexError, ValueError, KeyError) as err:
1139 logging.warning(f"No data for {name}\n{repr(err)}")
1143 file_type = plot.get(u"output-file-type", u".html")
1144 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
1145 layout = deepcopy(plot[u"layout"])
1146 if layout.get(u"title", None):
1147 layout[u"title"] = f"<b>Speedup Multi-core:</b> {layout[u'title']}"
1148 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
1149 layout[u"annotations"].extend(annotations)
1150 plpl = plgo.Figure(data=traces, layout=layout)
1157 filename=f"{plot[u'output-file']}{file_type}"
1159 except PlotlyError as err:
1161 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1166 def plot_http_server_perf_box(plot, input_data):
1167 """Generate the plot(s) with algorithm: plot_http_server_perf_box
1168 specified in the specification file.
1170 :param plot: Plot to generate.
1171 :param input_data: Data to process.
1172 :type plot: pandas.Series
1173 :type input_data: InputData
1176 # Transform the data
1178 f" Creating the data set for the {plot.get(u'type', u'')} "
1179 f"{plot.get(u'title', u'')}."
1181 data = input_data.filter_data(plot)
1183 logging.error(u"No data.")
1186 # Prepare the data for the plot
1191 if y_vals.get(test[u"name"], None) is None:
1192 y_vals[test[u"name"]] = list()
1194 y_vals[test[u"name"]].append(test[u"result"])
1195 except (KeyError, TypeError):
1196 y_vals[test[u"name"]].append(None)
1198 # Add None to the lists with missing data
1200 nr_of_samples = list()
1201 for val in y_vals.values():
1202 if len(val) > max_len:
1204 nr_of_samples.append(len(val))
1205 for val in y_vals.values():
1206 if len(val) < max_len:
1207 val.extend([None for _ in range(max_len - len(val))])
1211 df_y = pd.DataFrame(y_vals)
1213 for i, col in enumerate(df_y.columns):
1216 f"({nr_of_samples[i]:02d} " \
1217 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
1218 f"{col.lower().replace(u'-ndrpdr', u'')}"
1220 name_lst = name.split(u'-')
1223 for segment in name_lst:
1224 if (len(name) + len(segment) + 1) > 50 and split_name:
1227 name += segment + u'-'
1230 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
1236 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
1240 f" Writing file {plot[u'output-file']}"
1241 f"{plot[u'output-file-type']}."
1247 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
1249 except PlotlyError as err:
1251 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
1256 def plot_nf_heatmap(plot, input_data):
1257 """Generate the plot(s) with algorithm: plot_nf_heatmap
1258 specified in the specification file.
1260 :param plot: Plot to generate.
1261 :param input_data: Data to process.
1262 :type plot: pandas.Series
1263 :type input_data: InputData
1266 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
1267 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
1269 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
1272 # Transform the data
1274 f" Creating the data set for the {plot.get(u'type', u'')} "
1275 f"{plot.get(u'title', u'')}."
1277 data = input_data.filter_data(plot, continue_on_error=True)
1278 if data is None or data.empty:
1279 logging.error(u"No data.")
1285 for tag in test[u"tags"]:
1286 groups = re.search(regex_cn, tag)
1288 chain = str(groups.group(1))
1289 node = str(groups.group(2))
1293 groups = re.search(regex_test_name, test[u"name"])
1294 if groups and len(groups.groups()) == 3:
1296 f"{str(groups.group(1))}-"
1297 f"{str(groups.group(2))}-"
1298 f"{str(groups.group(3))}"
1302 if vals.get(chain, None) is None:
1303 vals[chain] = dict()
1304 if vals[chain].get(node, None) is None:
1305 vals[chain][node] = dict(
1313 if plot[u"include-tests"] == u"MRR":
1314 result = test[u"result"][u"receive-rate"]
1315 elif plot[u"include-tests"] == u"PDR":
1316 result = test[u"throughput"][u"PDR"][u"LOWER"]
1317 elif plot[u"include-tests"] == u"NDR":
1318 result = test[u"throughput"][u"NDR"][u"LOWER"]
1325 vals[chain][node][u"vals"].append(result)
1328 logging.error(u"No data.")
1334 txt_chains.append(key_c)
1335 for key_n in vals[key_c].keys():
1336 txt_nodes.append(key_n)
1337 if vals[key_c][key_n][u"vals"]:
1338 vals[key_c][key_n][u"nr"] = len(vals[key_c][key_n][u"vals"])
1339 vals[key_c][key_n][u"mean"] = \
1340 round(mean(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1341 vals[key_c][key_n][u"stdev"] = \
1342 round(stdev(vals[key_c][key_n][u"vals"]) / 1000000, 1)
1343 txt_nodes = list(set(txt_nodes))
1345 def sort_by_int(value):
1346 """Makes possible to sort a list of strings which represent integers.
1348 :param value: Integer as a string.
1350 :returns: Integer representation of input parameter 'value'.
1355 txt_chains = sorted(txt_chains, key=sort_by_int)
1356 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1358 chains = [i + 1 for i in range(len(txt_chains))]
1359 nodes = [i + 1 for i in range(len(txt_nodes))]
1361 data = [list() for _ in range(len(chains))]
1362 for chain in chains:
1365 val = vals[txt_chains[chain - 1]][txt_nodes[node - 1]][u"mean"]
1366 except (KeyError, IndexError):
1368 data[chain - 1].append(val)
1371 my_green = [[0.0, u"rgb(235, 249, 242)"],
1372 [1.0, u"rgb(45, 134, 89)"]]
1374 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1375 [1.0, u"rgb(57, 115, 172)"]]
1377 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1378 [1.0, u"rgb(102, 102, 102)"]]
1381 annotations = list()
1383 text = (u"Test: {name}<br>"
1388 for chain, _ in enumerate(txt_chains):
1390 for node, _ in enumerate(txt_nodes):
1391 if data[chain][node] is not None:
1400 text=str(data[chain][node]),
1408 hover_line.append(text.format(
1409 name=vals[txt_chains[chain]][txt_nodes[node]][u"name"],
1410 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1411 val=data[chain][node],
1412 stdev=vals[txt_chains[chain]][txt_nodes[node]][u"stdev"]))
1413 hovertext.append(hover_line)
1421 title=plot.get(u"z-axis", u""),
1435 colorscale=my_green,
1441 for idx, item in enumerate(txt_nodes):
1459 for idx, item in enumerate(txt_chains):
1486 text=plot.get(u"x-axis", u""),
1503 text=plot.get(u"y-axis", u""),
1512 updatemenus = list([
1523 u"colorscale": [my_green, ],
1524 u"reversescale": False
1533 u"colorscale": [my_blue, ],
1534 u"reversescale": False
1543 u"colorscale": [my_grey, ],
1544 u"reversescale": False
1555 layout = deepcopy(plot[u"layout"])
1556 except KeyError as err:
1557 logging.error(f"Finished with error: No layout defined\n{repr(err)}")
1560 layout[u"annotations"] = annotations
1561 layout[u'updatemenus'] = updatemenus
1565 plpl = plgo.Figure(data=traces, layout=layout)
1568 logging.info(f" Writing file {plot[u'output-file']}.html")
1573 filename=f"{plot[u'output-file']}.html"
1575 except PlotlyError as err:
1577 f" Finished with error: {repr(err)}".replace(u"\n", u" ")