Constant time
This commit is contained in:
parent
3ef86c3593
commit
7ae94371a8
5 changed files with 81 additions and 24 deletions
58
plots.py
58
plots.py
|
|
@ -483,6 +483,62 @@ def cmp_versions(logs, exps, criteria, objs):
|
|||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
def tabulate(lines):
|
||||
widths = [0] * len(lines[0])
|
||||
for line in lines:
|
||||
for col in range(len(line)):
|
||||
if len(line[col]) > widths[col]:
|
||||
widths[col] = len(line[col])
|
||||
table = ""
|
||||
for line in lines:
|
||||
for col in range(len(line)):
|
||||
if col > 0:
|
||||
table += " "
|
||||
table += line[col]
|
||||
table += " " * (widths[col] - len(line[col]))
|
||||
table += "\n"
|
||||
return table
|
||||
|
||||
def make_summary(logs):
|
||||
plain_result_key = lambda log: (log["exp"], log["side"])
|
||||
result_key = lambda log: (log["exp"], log["side"], log["impl"], log["alg"], log["kex"], log["cipher"], log["ed"])
|
||||
|
||||
plain_results = {}
|
||||
results = {}
|
||||
idle_val = None
|
||||
|
||||
for log in logs:
|
||||
if log["exp"] == "idle":
|
||||
idle_val = {
|
||||
"cpu": float(log["cpu"]) / float(log["time"]),
|
||||
"energy": float(log["Wh"]) / float(log["time"]) * 3600,
|
||||
}
|
||||
if log["tls"] == "0":
|
||||
n = float(log.get("n", "1000"))
|
||||
plain_results[plain_result_key(log)] = {
|
||||
"cpu": (float(log["cpu"]) - idle_val["cpu"] * float(log["time"])) / n,
|
||||
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n
|
||||
}
|
||||
if log["exp"] != "idle" and log["tls"] == "1":
|
||||
n = float(log.get("n", "1000"))
|
||||
results[result_key(log)] = {
|
||||
"cpu": (float(log["cpu"]) - idle_val["cpu"] * float(log["time"])) / n,
|
||||
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n
|
||||
}
|
||||
|
||||
lines = [["key", "idle (W)", "no_tls (Ws/S)", "tls (Ws/S)", "tls_only (1)"]]
|
||||
for k in results:
|
||||
no_tls = plain_results[k[:2]]["energy"]
|
||||
tls = results[k]["energy"]
|
||||
lines.append([
|
||||
"/".join([str(i) for i in k]),
|
||||
str(idle_val["energy"]),
|
||||
str(no_tls),
|
||||
str(tls),
|
||||
str((tls - no_tls) / tls),
|
||||
])
|
||||
print(tabulate(lines))
|
||||
|
||||
def getargv(arg:str, default="", n:int=1, args:list=sys.argv):
|
||||
if arg in args and len(args) > args.index(arg)+n:
|
||||
return args[args.index(arg)+n]
|
||||
|
|
@ -537,6 +593,8 @@ if __name__ == "__main__":
|
|||
make_profile_plot_grouped(logs, "impl-cipher-ver", "cipher", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot_grouped(logs, "impl-cert-ver", "cert", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot_grouped(logs, "impl-kex-ver", "kex", side, record, "impl", no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
elif cmd == "summary":
|
||||
make_summary(logs)
|
||||
elif cmd == "correl":
|
||||
from scipy import stats
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue