summaryrefslogtreecommitdiff
path: root/nemesis/html_gen.py
diff options
context:
space:
mode:
Diffstat (limited to 'nemesis/html_gen.py')
-rw-r--r--nemesis/html_gen.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/nemesis/html_gen.py b/nemesis/html_gen.py
new file mode 100644
index 0000000..b774da9
--- /dev/null
+++ b/nemesis/html_gen.py
@@ -0,0 +1,77 @@
+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=3, cols=1)
+
+ for i, (coro_name, x_values) in enumerate(results.items(), start=1):
+ x_list = []
+ y_latency_list = []
+ y_throughput_list = []
+ y_max_latency_list = []
+
+ for speedup, experiments in x_values.items():
+ for experiment in experiments:
+
+ completed_callbacks = experiment["latency"]
+ virtual_run_time = experiment["virtual_run_time"][0]
+
+ x_list.append(speedup * 100)
+
+ num_callbacks = len(completed_callbacks)
+
+ # handle average latency graph
+ if num_callbacks > 0:
+
+ total_wait = sum([cb[1] for cb in completed_callbacks])
+ max_wait = max([cb[1] for cb in completed_callbacks])
+ latency = total_wait / num_callbacks
+
+ y_max_latency_list.append(max_wait)
+ y_latency_list.append(latency)
+ else:
+ y_latency_list.append(0)
+
+ # handle throughput graph
+ throughput = num_callbacks / virtual_run_time
+ y_throughput_list.append(throughput)
+
+ fig.add_trace(go.Scatter(
+ x=x_list,
+ y=y_latency_list,
+ mode='markers',
+ name=coro_name,
+ 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,
+ marker=dict(color=get_color(coro_name)),
+ showlegend=False,
+ ), row=2, col=1)
+
+ fig.add_trace(go.Scatter(
+ x=x_list,
+ y=y_max_latency_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 (% optimized away)", row=3, col=1)
+ fig.update_yaxes(title_text="Average Handle Latency (seconds)", row=1, col=1)
+ fig.update_yaxes(title_text="Throughput (callbacks per second)", row=2, col=1)
+ fig.update_yaxes(title_text="Maximum Handle Latency (seconds)", row=3, col=1)
+
+ fig.write_html(filename)