- # Add None to the lists with missing data
- max_len = 0
- nr_of_samples = list()
- for val in y_sorted.values():
- if len(val) > max_len:
- max_len = len(val)
- nr_of_samples.append(len(val))
- for key, val in y_sorted.items():
- if len(val) < max_len:
- val.extend([None for _ in range(max_len - len(val))])
-
- # Add plot traces
- traces = list()
- df = pd.DataFrame(y_sorted)
- df.head()
- y_max = list()
- for i, col in enumerate(df.columns):
- tst_name = re.sub(REGEX_NIC, "",
- col.lower().replace('-ndrpdr', '').
- replace('2n1l-', ''))
- name = "{nr}. ({samples:02d} run{plural}) {name}".\
- format(nr=(i + 1),
- samples=nr_of_samples[i],
- plural='s' if nr_of_samples[i] > 1 else '',
- name=tst_name)
-
- logging.debug(name)
- traces.append(plgo.Box(x=[str(i + 1) + '.'] * len(df[col]),
- y=[y / 1000000 if y else None for y in df[col]],
- name=name,
- **plot["traces"]))
- try:
- val_max = max(df[col])
- except ValueError as err:
- logging.error(repr(err))
- continue
- if val_max:
- y_max.append(int(val_max / 1000000) + 1)
-
- try:
- # Create plot
- layout = deepcopy(plot["layout"])
- if layout.get("title", None):
- layout["title"] = "<b>Throughput:</b> {0}". \
- format(layout["title"])
- if y_max:
- layout["yaxis"]["range"] = [0, max(y_max)]
- plpl = plgo.Figure(data=traces, layout=layout)
-
- # Export Plot
- logging.info(" Writing file '{0}{1}'.".
- format(plot["output-file"], plot["output-file-type"]))
- ploff.plot(plpl, show_link=False, auto_open=False,
- filename='{0}{1}'.format(plot["output-file"],
- plot["output-file-type"]))
- except PlotlyError as err:
- logging.error(" Finished with error: {}".
- format(repr(err).replace("\n", " ")))