diff options
Diffstat (limited to 'nemesis/html_gen.py')
-rw-r--r-- | nemesis/html_gen.py | 79 |
1 files changed, 62 insertions, 17 deletions
diff --git a/nemesis/html_gen.py b/nemesis/html_gen.py index ea7df15..44c7d56 100644 --- a/nemesis/html_gen.py +++ b/nemesis/html_gen.py @@ -1,38 +1,83 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots +import hashlib + +def get_color(name): + hash_object = hashlib.md5(name.encode()) + color_index = int(hash_object.hexdigest(), 16) % 360 + return f'hsl({color_index}, 100%, 50%)' def plot_results(results, filename): - fig = make_subplots(rows=len(results), cols=1, shared_xaxes=True) + fig = make_subplots(rows=3, cols=1, shared_xaxes=True) for i, (coro_name, x_values) in enumerate(results.items(), start=1): x_list = [] - y_list = [] - hover_text = [] + y_starve_list = [] + y_throughput_list = [] + y_time_in_coro_list = [] + starve_hover_text = [] + throughput_hover_text = [] for speedup, experiments in x_values.items(): for experiment in experiments: - y_value = sum(experiment.values()) + starve = experiment["time_starving"] + processed = experiment["processed"] + time_in_coro = experiment["time_in_coro"] + real_duration = experiment["real_duration"] x_list.append(speedup) - y_list.append(y_value) - breakdown = "<br>".join([f" {key[0]} ({key[1]}): {round(value, 4)}" for key, value in experiment.items()]) - hover_text.append(f"{coro_name}<br>Speedup: {speedup}<br>Total Wait: {round(y_value, 4)}<br>Breakdown:<br>{breakdown}") + # handle starve graph + starve_time = sum(starve.values()) + y_starve_list.append(starve_time) + + breakdown = "<br>".join([f" {key[0]} ({key[1]}): {round(value, 4)}" for key, value in starve.items()]) + starve_hover_text.append(f"({speedup}, {round(starve_time, 4)})<br>{coro_name}<br>Breakdown:<br>{breakdown}") + + # handle throughput graph + throughput = (speedup * processed) / real_duration + y_throughput_list.append(throughput) + + throughput_hover_text.append(f"({speedup}, {round(throughput, 4 )})<br>{coro_name}<br>True experiment duration: {round(real_duration, 4)}<br>Total Processed: {processed}") + + # handle time in coro graph + y_time_in_coro_list.append(time_in_coro / speedup) fig.add_trace(go.Scatter( x=x_list, - y=y_list, + y=y_starve_list, mode='markers', name=coro_name, hoverinfo='text', - hovertext=hover_text, - )) - - fig.update_layout( - title="Potential Speedups for ", - xaxis_title="Speedup (times faster)", - yaxis_title="Total Wait (seconds)", - showlegend=True, - ) + hovertext=starve_hover_text, + marker=dict(color=get_color(coro_name)), + showlegend=True, + ), row=1, col=1) + + fig.add_trace(go.Scatter( + x=x_list, + y=y_throughput_list, + mode='markers', + name=coro_name, + hovertext=throughput_hover_text, + marker=dict(color=get_color(coro_name)), + showlegend=False, + ), row=2, col=1) + + fig.add_trace(go.Scatter( + x=x_list, + y=y_time_in_coro_list, + mode='markers', + name=coro_name, + marker=dict(color=get_color(coro_name)), + showlegend=False, + ), row=3, col=1) + + fig.update_xaxes(title_text="Speedup (times faster)", row=1, col=1) + fig.update_xaxes(title_text="Speedup (times faster)", row=2, col=1) + fig.update_xaxes(title_text="Speedup (times faster)", row=3, col=1) + fig.update_yaxes(title_text="Total Starvation Time (seconds)", row=1, col=1) + fig.update_yaxes(title_text="Total Throughput (handles per second)", row=2, col=1) + fig.update_yaxes(title_text="Synchronous Time in Coroutine (seconds)", row=3, col=1) fig.write_html(filename) |