Fix kill, makecerts, summary

This commit is contained in:
Pascal Engélibert 2026-03-25 09:49:10 +01:00
commit c311c4626b
3 changed files with 64 additions and 35 deletions

View file

@ -490,18 +490,24 @@ def tabulate(lines):
if len(line[col]) > widths[col]:
widths[col] = len(line[col])
table = ""
ruler = False
for line in lines:
for col in range(len(line)):
if col > 0:
table += " "
table += line[col]
table += " " * (widths[col] - len(line[col]))
rem = widths[col] - len(line[col])
if ruler:
table += " " * (rem % 4) + " · " * (rem // 4)
else:
table += " " * rem
table += "\n"
ruler = not ruler
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_result_key = lambda log: (log["exp"], log["side"], log["record"])
result_key = lambda log: (log["exp"], log["side"], log["record"], log["impl"], log["alg"], log["kex"], log["cipher"], log["ed"])
plain_results = {}
results = {}
@ -512,30 +518,38 @@ def make_summary(logs):
idle_val = {
"cpu": float(log["cpu"]) / float(log["time"]),
"energy": float(log["Wh"]) / float(log["time"]) * 3600,
"in": float(log["bytes_in"]) / float(log["time"]),
"out": float(log["bytes_out"]) / float(log["time"]),
}
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
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n,
"in": (float(log["bytes_in"]) - idle_val["in"] * float(log["time"])) / n,
"out": (float(log["bytes_out"]) - idle_val["out"] * 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
"energy": (float(log["Wh"]) * 3600 - idle_val["energy"] * float(log["time"])) / n,
"in": (float(log["bytes_in"]) - idle_val["in"] * float(log["time"])) / n,
"out": (float(log["bytes_out"]) - idle_val["out"] * float(log["time"])) / n,
}
lines = [["key", "idle (W)", "no_tls (Ws/S)", "tls (Ws/S)", "tls_only (1)"]]
lines = [["key", "idle (W)", "no_tls (Ws/S)", "tls (Ws/S)", "tls_only (Ws/S)", "tls_in (1)", "tls_out (1)"]]
for k in results:
no_tls = plain_results[k[:2]]["energy"]
tls = results[k]["energy"]
r = results[k]
p = plain_results[k[:3]]
lines.append([
"/".join([str(i) for i in k]),
str(idle_val["energy"]),
str(no_tls),
str(tls),
str((tls - no_tls) / tls),
str(p["energy"]),
str(r["energy"]),
str(r["energy"] - p["energy"]),
str((r["in"] - p["in"]) / r["in"]),
str((r["out"] - p["out"]) / r["out"]),
])
print(tabulate(lines))