-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse_bench.py
96 lines (80 loc) · 2.65 KB
/
parse_bench.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
/* Copyright 2022 UCLouvain, Belgium and PQM4 contributors
*
* This file is part of pqm4_masked.
*
* pqm4_masked is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* pqm4_masked is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* pqm4_masked. If not, see <https://www.gnu.org/licenses/>.
*/
"""
import csv
import pandas
import numpy as np
import sys
import matplotlib.pyplot as plt
ds = np.arange(2,16)
target = sys.argv[1]
implem = sys.argv[2]
rnd_name = f"{target}_{implem}_rnd.csv"
cycles_name = f"{target}_{implem}_cycles.csv"
if target == "kyber768":
benchs = ['my_cmp_finalize',"decaps","keccak",
'my_masked_poly_cmp',"my_cbd","my_frommsg","my_tomsg","my_matacc","my_ntt"]
#benchs +=["my_dense2bs","my_bs2dense"]
#benchs += ["my_secadd","my_seca2b"]
elif target == "saber":
benchs = ["decaps","keccak",
"my_cbd","my_cmp_finalize",
"my_masked_poly_cmp","my_matacc","my_ntt","my_tomsg"]
def get_perf(df,l,k):
for x in l:
df = df[df[x[0]].isin([x[1]])]
return int(df[k])
def extract_all(df,ds,names,k):
dic = {}
for n in names:
cycles_k = np.array([get_perf(df,
[("case","decaps"),
("shares",d),
("bench",n)],k) for d in ds])
dic[n] = cycles_k
return dic
if __name__ == "__main__":
df = pandas.read_csv(cycles_name)
cycles = extract_all(df,ds,benchs,"perf")
df = pandas.read_csv(rnd_name)
rnds = extract_all(df,ds,benchs,"perf")
# print raw numbers
plt.figure()
for k,cycle in cycles.items():
plt.semilogy(ds,cycle,label=k)
plt.legend()
plt.grid(True,which="both",ls="--")
# print percentage
plt.figure()
full = 0
for k,cycle in cycles.items():
if k == "decaps":
continue
plt.plot(ds,cycle/cycles["decaps"],label=k)
full += cycle
plt.plot(ds,(cycles["decaps"] - full) / cycles["decaps"],label="others")
plt.legend()
plt.grid(True,which="both",ls="--")
# print rnd ratio numbers
plt.figure()
plt.title("rnd proportion")
for (k,cycle),(_,rnd) in zip(cycles.items(),rnds.items()):
plt.plot(ds,rnd*53/cycle,label=k)
plt.legend()
plt.grid(True,which="both",ls="--")
plt.show()