Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Update graphics
Browse files Browse the repository at this point in the history
Closes #8
Closes #9
  • Loading branch information
jiep committed Feb 15, 2022
1 parent 6e19366 commit 12aaa89
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 156 deletions.
188 changes: 109 additions & 79 deletions graphics/generate_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@
from matplotlib import pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

COLORS = {
'Classic-McEliece-348864': "#372101" ,
'Classic-McEliece-348864f': "#A77500",
'Classic-McEliece-460896': "#1CE6FF",
'Classic-McEliece-460896f': "#FF34FF",
'Classic-McEliece-6688128': "#FF4A46",
'Classic-McEliece-6688128f': "#008941",
'Classic-McEliece-6960119': "#006FA6",
'Classic-McEliece-6960119f': "#A30059",
'Classic-McEliece-8192128': "#6A3A4C",
'Classic-McEliece-8192128f': "#7A4900",
'Kyber512': "#0000A6",
'Kyber768': "#63FFAC",
'Kyber1024': "#B79762",
'NTRU-HPS-2048-509': "#004D43",
'NTRU-HPS-2048-677': "#5A0007",
'NTRU-HRSS-701': "#809693",
'NTRU-HPS-4096-821': "#0089A3",
'LightSaber-KEM': "#1B4400",
'Saber-KEM': "#4FC601",
'FireSaber-KEM': "#3B5DFF"
}

def plot_scalability_level(data, config):

Expand All @@ -27,7 +49,7 @@ def conditions(s):
else:
return ""

fig, axes = plt.subplots(3, figsize=(15,15))
fig, axes = plt.subplots(3, figsize=(15,15), sharey=True)
fig.suptitle('Scalability', fontsize=30)
fig.subplots_adjust(hspace=0.75, wspace=0.4)

Expand All @@ -38,11 +60,15 @@ def conditions(s):
print(data)
df2 = df2.groupby(['algorithm','N'])['mean_cpu_cycles'].sum().reset_index()
print(df2)
sns.lineplot(ax=axes[j], x="N", y="mean_cpu_cycles", hue="algorithm", data=df2)
p = sns.lineplot(ax=axes[j], x="N", y="mean_cpu_cycles", hue="algorithm", data=df2, palette=COLORS, linewidth=2, style="algorithm", markers=True, dashes=False)
axes[j].set_title("Level {}".format(LEVELS_LABELS[j]), fontsize="x-large")
axes[j].set_xlabel('Number of parties', fontsize="x-large")
axes[j].set_ylabel('CPU Cycles', fontsize="x-large")

h, l = p.get_legend_handles_labels()
l, h = zip(*sorted(zip(l, h)))
p.legend(h, l)

figname = "{}/{}/scalability_level.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
fig.savefig(figname)
print("Saved file to {}".format(figname), flush=True)
Expand All @@ -57,10 +83,14 @@ def plot_scalability(data, config):
print(data)
df2 = df2.groupby(['algorithm','N'])['mean_cpu_cycles'].sum().reset_index()
print(df2)
sns.lineplot(ax=axes, x="N", y="mean_cpu_cycles", hue="algorithm", data=df2)
p = sns.lineplot(ax=axes, x="N", y="mean_cpu_cycles", hue="algorithm", data=df2, palette=COLORS, linewidth=2, style="algorithm", markers=True, dashes=False)
axes.set_xlabel('Number of parties', fontsize="x-large")
axes.set_ylabel('CPU Cycles', fontsize="x-large")

h, l = p.get_legend_handles_labels()
l, h = zip(*sorted(zip(l, h)))
p.legend(h, l)

figname = "{}/{}/scalability.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
fig.savefig(figname)
print("Saved file to {}".format(figname), flush=True)
Expand Down Expand Up @@ -158,7 +188,7 @@ def plot_heatmap(data, config):

def plot_speed_commitment(data, config):

fig, axes = plt.subplots(3,4, figsize=(25,25))
fig, axes = plt.subplots(3,3, figsize=(25,25), sharey=False)
fig.suptitle('Commitment operations', fontsize=30)
fig.subplots_adjust(hspace=0.75, wspace=0.4)

Expand All @@ -177,8 +207,9 @@ def conditions(s):

data["level"] = data.apply(conditions, axis=1)

operations = ['init', 'commit', 'check']
operations_names = ['Init', 'Commit', 'Check']
operations = ['commit', 'check']
operations_names = ['Commit', 'Check']
plt.yscale('log',base=10)
for (i, var) in enumerate(operations):
for (j, level) in enumerate(LEVELS):
df = data[(data['operation'] == var) & data['algorithm'].isin(level)]
Expand All @@ -190,23 +221,23 @@ def conditions(s):
# with pd.option_context('display.max_rows', None, 'display.max_columns', None):
# print(df2)

if i == 0:
axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
horizontalalignment='center',
verticalalignment='center',
transform=axes[j,i].transAxes,
fontsize="xx-large"
)
axes[j,i].axis('off')


sns.barplot(ax=axes[j,i+1], x="algorithm", y="mean_cpu_cycles", data=df2)
axes[j,i+1].set_title(operations_names[i], fontsize="x-large")
# axes[j,i+1].legend(loc='upper left')
axes[j,i+1].tick_params(axis='x', rotation=90)
axes[j,i+1].set(yscale="log")
axes[j,i+1].set_xlabel('', fontsize="x-large")
axes[j,i+1].set_ylabel('CPU Cycles', fontsize="x-large")
# if i == 0:
# axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
# horizontalalignment='center',
# verticalalignment='center',
# transform=axes[j,i].transAxes,
# fontsize="xx-large"
# )
# axes[j,i].axis('off')


sns.barplot(ax=axes[j,i], x="algorithm", y="mean_cpu_cycles", data=df2, palette=COLORS)
axes[j,i].set_title(operations_names[i], fontsize="x-large")
# axes[j,i].legend(loc='upper left')
axes[j,i].tick_params(axis='x', rotation=90)
axes[j,i].set(yscale="log")
axes[j,i].set_xlabel('', fontsize="x-large")
axes[j,i].set_ylabel('CPU Cycles', fontsize="x-large")
# axes[j,i+1].axis('equal')

figname = "{}/{}/cycles_level_commitment.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
Expand All @@ -215,8 +246,8 @@ def conditions(s):

def plot_speed_gake(data, config):

fig, axes = plt.subplots(3,5, figsize=(25,25))
fig.suptitle('AKE operations', fontsize=30)
fig, axes = plt.subplots(3,4, figsize=(25,25), sharey=True)
fig.suptitle('GAKE operations', fontsize=30)
fig.subplots_adjust(hspace=0.75, wspace=0.4)

LEVELS = [config["L1"], config["L3"], config["L5"]]
Expand Down Expand Up @@ -247,23 +278,23 @@ def conditions(s):
# with pd.option_context('display.max_rows', None, 'display.max_columns', None):
# print(df2)

if i == 0:
axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
horizontalalignment='center',
verticalalignment='center',
transform=axes[j,i].transAxes,
fontsize="xx-large"
)
axes[j,i].axis('off')


sns.barplot(ax=axes[j,i+1], x="algorithm", y="mean_cpu_cycles", data=df2)
axes[j,i+1].set_title(operations_names[i], fontsize="x-large")
# axes[j,i+1].legend(loc='upper left')
axes[j,i+1].tick_params(axis='x', rotation=90)
axes[j,i+1].set(yscale="log")
axes[j,i+1].set_xlabel('', fontsize="x-large")
axes[j,i+1].set_ylabel('CPU Cycles', fontsize="x-large")
# if i == 0:
# axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
# horizontalalignment='center',
# verticalalignment='center',
# transform=axes[j,i].transAxes,
# fontsize="xx-large"
# )
# axes[j,i].axis('off')


sns.barplot(ax=axes[j,i], x="algorithm", y="mean_cpu_cycles", data=df2, palette=COLORS)
axes[j,i].set_title(operations_names[i], fontsize="x-large")
# axes[j,i].legend(loc='upper left')
axes[j,i].tick_params(axis='x', rotation=90)
axes[j,i].set(yscale="log")
axes[j,i].set_xlabel('', fontsize="x-large")
axes[j,i].set_ylabel('CPU Cycles', fontsize="x-large")
# axes[j,i+1].axis('equal')

figname = "{}/{}/cycles_level_gake.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
Expand All @@ -272,7 +303,7 @@ def conditions(s):

def plot_speed_ake(data, config):

fig, axes = plt.subplots(3,4, figsize=(25,25))
fig, axes = plt.subplots(3,3, figsize=(25,25), sharey=True)
fig.suptitle('AKE operations', fontsize=30)
fig.subplots_adjust(hspace=0.75, wspace=0.4)

Expand All @@ -292,7 +323,7 @@ def conditions(s):
data["level"] = data.apply(conditions, axis=1)

operations = ['init', 'algA', 'algB']
operations_names = ['Init', 'Alg A', 'Alg B']
operations_names = ['Init', 'AlgA', 'AlgB']
for (i, var) in enumerate(operations):
for (j, level) in enumerate(LEVELS):
df = data[(data['operation'] == var) & data['algorithm'].isin(level)]
Expand All @@ -304,23 +335,22 @@ def conditions(s):
# with pd.option_context('display.max_rows', None, 'display.max_columns', None):
# print(df2)

if i == 0:
axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
horizontalalignment='center',
verticalalignment='center',
transform=axes[j,i].transAxes,
fontsize="xx-large"
)
axes[j,i].axis('off')


sns.barplot(ax=axes[j,i+1], x="algorithm", y="mean_cpu_cycles", data=df2)
axes[j,i+1].set_title(operations_names[i], fontsize="x-large")
# axes[j,i+1].legend(loc='upper left')
axes[j,i+1].tick_params(axis='x', rotation=90)
axes[j,i+1].set(yscale="log")
axes[j,i+1].set_xlabel('', fontsize="x-large")
axes[j,i+1].set_ylabel('CPU Cycles', fontsize="x-large")
# if i == 0:
# axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
# horizontalalignment='center',
# verticalalignment='center',
# transform=axes[j,i].transAxes,
# fontsize="xx-large"
# )
# axes[j,i].axis('off')

sns.barplot(ax=axes[j,i], x="algorithm", y="mean_cpu_cycles", data=df2, palette=COLORS)
axes[j,i].set_title(operations_names[i], fontsize="x-large")
# axes[j,i].legend(loc='upper left')
axes[j,i].tick_params(axis='x', rotation=90)
axes[j,i].set(yscale="log")
axes[j,i].set_xlabel('', fontsize="x-large")
axes[j,i].set_ylabel('CPU Cycles', fontsize="x-large")
# axes[j,i+1].axis('equal')

figname = "{}/{}/cycles_level_ake.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
Expand All @@ -342,7 +372,7 @@ def conditions(s):
else:
return ""

fig, axes = plt.subplots(3,4, figsize=(25,25))
fig, axes = plt.subplots(3,3, figsize=(25,25), sharey=True)
fig.suptitle('KEM operations', fontsize=30)
fig.subplots_adjust(hspace=0.75, wspace=0.4)

Expand All @@ -361,23 +391,23 @@ def conditions(s):
# with pd.option_context('display.max_rows', None, 'display.max_columns', None):
# print(df2)

if i == 0:
axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
horizontalalignment='center',
verticalalignment='center',
transform=axes[j,i].transAxes,
fontsize="xx-large"
)
axes[j,i].axis('off')


sns.barplot(ax=axes[j,i+1], x="algorithm", y="mean_cpu_cycles", data=df2)
axes[j,i+1].set_title(operations_names[i], fontsize="x-large")
# axes[j,i+1].legend(loc='upper left')
axes[j,i+1].tick_params(axis='x', rotation=90)
axes[j,i+1].set(yscale="log")
axes[j,i+1].set_xlabel('', fontsize="x-large")
axes[j,i+1].set_ylabel('CPU Cycles', fontsize="x-large")
# if i == 0:
# axes[j,i].text(0.8, 0.5, 'Level {}'.format(LEVELS_LABELS[j]),
# horizontalalignment='center',
# verticalalignment='center',
# transform=axes[j,i].transAxes,
# fontsize="xx-large"
# )
# axes[j,i].axis('off')


sns.barplot(ax=axes[j,i], x="algorithm", y="mean_cpu_cycles", data=df2, palette=COLORS)
axes[j,i].set_title(operations_names[i], fontsize="x-large")
# axes[j,i].legend(loc='upper left')
axes[j,i].tick_params(axis='x', rotation=90)
axes[j,i].set(yscale="log")
axes[j,i].set_xlabel('', fontsize="x-large")
axes[j,i].set_ylabel('CPU Cycles', fontsize="x-large")
# axes[j,i+1].axis('equal')

figname = "{}/{}/cycles_level_kem.png".format(config["FOLDER"], config["OUTPUT_FOLDER"])
Expand Down
Loading

0 comments on commit 12aaa89

Please sign in to comment.