From 954fd6d30b756502c2ddbdd15d2857bd785fb31e Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Tue, 9 Apr 2024 15:40:27 +0200
Subject: [PATCH] plot commit for all curves

---
 benches/plot.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/benches/plot.py b/benches/plot.py
index 6272be95..58acd8c8 100644
--- a/benches/plot.py
+++ b/benches/plot.py
@@ -162,8 +162,13 @@ def plot_commit(data: Data, save: bool = False):
     fig, ax = plt.subplots(1, 1, figsize=(16, 9))
 
     # key: the start of the `$.id` field
-    def plot(data: Data, key: str, color: str, ax):
-        filtered_data = list(filter(lambda line: line["id"].startswith(key), data))
+    def plot(data: Data, key: str, curve: str, style: str, color: str, ax):
+        filtered_data = list(filter(
+            lambda line: line["id"].startswith(key) and line["id"].endswith(f" on {curve}"),
+            data
+        ))
+        if len(filtered_data) == 0:
+            return
 
         sizes = [
             int(line["id"].lstrip(key).split(' ')[0]) for line in filtered_data
@@ -173,14 +178,12 @@ def plot_commit(data: Data, save: bool = False):
         up = ns_to_ms(extract(filtered_data, "mean", "upper_bound"))
         down = ns_to_ms(extract(filtered_data, "mean", "lower_bound"))
 
-        ax.plot(sizes, means, label=key, color=color)
-        ax.fill_between(sizes, down, up, color=color, alpha=0.3)
-
-    keys = ["commit (komodo)", "commit (arkworks)"]
-    colors = ["blue", "orange"]
+        ax.plot(sizes, means, label=f"{key} on {curve}", color=color, linestyle=style)
+        ax.fill_between(sizes, down, up, color=color, linestyle=style, alpha=0.3)
 
-    for (k, c) in zip(keys, colors):
-        plot(data, key=k, color=c, ax=ax)
+    for (curve, color) in [("BLS12-381", "blue"), ("BN-254", "orange"), ("PALLAS", "green")]:
+        plot(data, key="commit (komodo)", curve=curve, style="solid", color=color, ax=ax)
+        plot(data, key="commit (arkworks)", curve=curve, style="dashed", color=color, ax=ax)
 
     ax.set_title("commit times")
     ax.set_ylabel("time (in ms)")
-- 
GitLab