Tx summary
This commit is contained in:
parent
eba08d3b8b
commit
e98eb7380a
4 changed files with 146 additions and 4 deletions
136
plots.py
136
plots.py
|
|
@ -573,6 +573,125 @@ def make_summary(logs):
|
|||
])
|
||||
print(tabulate(lines))
|
||||
|
||||
def analyze_logs(logs):
|
||||
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 = {}
|
||||
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,
|
||||
"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,
|
||||
"total_energy": float(log["Wh"]) * 3600 / 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)] = {
|
||||
"exp": log["exp"],
|
||||
"side": log["side"],
|
||||
"record": log["record"],
|
||||
"impl": log["impl"],
|
||||
"alg": log["alg"],
|
||||
"kex": log["kex"],
|
||||
"cipher": log["cipher"],
|
||||
"ed": log["ed"],
|
||||
"cpu": (float(log["cpu"]) - idle_val["cpu"] * float(log["time"])) / n,
|
||||
"total_energy": float(log["Wh"]) * 3600 / 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 = []
|
||||
for k in results:
|
||||
r = results[k]
|
||||
p = plain_results[k[:3]]
|
||||
lines.append({
|
||||
"exp": r["exp"],
|
||||
"side": r["side"],
|
||||
"record": r["record"],
|
||||
"impl": r["impl"],
|
||||
"alg": r["alg"],
|
||||
"kex": r["kex"],
|
||||
"cipher": r["cipher"],
|
||||
"ed": r["ed"],
|
||||
"tls": r,
|
||||
"plain": p,
|
||||
})
|
||||
return lines
|
||||
|
||||
def make_tx_summary(client_logs, server_logs):
|
||||
client_results = analyze_logs(client_logs)
|
||||
server_results = analyze_logs(server_logs)
|
||||
txs = []
|
||||
lines = [["exp", "record", "alg", "kex", "cipher", "ed", "client", "server", "plain (J/S)", "TLS (J/S)", "TLS only (J/S)", "TLS rel"]]
|
||||
for client in client_results:
|
||||
#print("client", client)
|
||||
if client["side"] != "client":
|
||||
continue
|
||||
for server in server_results:
|
||||
#print("server", server)
|
||||
if server["side"] != "server":
|
||||
continue
|
||||
#print(client, server)
|
||||
if client["exp"] == server["exp"] \
|
||||
and client["record"] == server["record"] \
|
||||
and client["alg"] == server["alg"] \
|
||||
and client["kex"] == server["kex"] \
|
||||
and client["cipher"] == server["cipher"] \
|
||||
and client["ed"] == server["ed"]:
|
||||
plain_io_avg = (client["plain"]["in"] + client["plain"]["out"] + server["plain"]["in"] + server["plain"]["out"]) / 2
|
||||
tls_io_avg = (client["tls"]["in"] + client["tls"]["out"] + server["tls"]["in"] + server["tls"]["out"]) / 2
|
||||
tls_only_io_avg = tls_io_avg - plain_io_avg
|
||||
plain_energy = client["plain"]["energy"] + server["plain"]["energy"] + plain_io_avg * WS_PER_BYTE
|
||||
tls_energy = client["tls"]["energy"] + server["tls"]["energy"] + tls_io_avg * WS_PER_BYTE
|
||||
tls_only_energy = tls_energy - plain_energy
|
||||
tls_rel_energy = tls_only_energy / plain_energy
|
||||
txs.append({
|
||||
"exp": client["exp"],
|
||||
"record": client["record"],
|
||||
"alg": client["alg"],
|
||||
"kex": client["kex"],
|
||||
"cipher": client["cipher"],
|
||||
"ed": client["ed"],
|
||||
"client_impl": client["impl"],
|
||||
"server_impl": server["impl"],
|
||||
"plain_energy": plain_energy,
|
||||
"tls_energy": tls_energy,
|
||||
"tls_only_energy": tls_only_energy,
|
||||
"tls_rel_energy": tls_rel_energy,
|
||||
})
|
||||
lines.append([
|
||||
client["exp"],
|
||||
client["record"],
|
||||
client["alg"],
|
||||
client["kex"],
|
||||
client["cipher"],
|
||||
client["ed"],
|
||||
client["impl"],
|
||||
server["impl"],
|
||||
str(round(plain_energy, 2)),
|
||||
str(round(tls_energy, 2)),
|
||||
str(round(tls_only_energy, 2)),
|
||||
str(round(tls_rel_energy*100, 2))+"%",
|
||||
])
|
||||
|
||||
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]
|
||||
|
|
@ -629,6 +748,23 @@ if __name__ == "__main__":
|
|||
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 == "tx":
|
||||
logfile_name = sys.argv[2]
|
||||
logfile = open(logfile_name, "r")
|
||||
lines = logfile.readlines()
|
||||
logfile.close()
|
||||
colnames = lines[0].removesuffix("\n").split(" ")
|
||||
logs2 = []
|
||||
records = {}
|
||||
for line in lines[1:]:
|
||||
cols = line.removesuffix("\n").split(" ")
|
||||
log = {}
|
||||
for col in range(len(cols)):
|
||||
log[colnames[col]] = cols[col]
|
||||
if log["record"] != "-":
|
||||
records[log["record"]] = ()
|
||||
logs2.append(log)
|
||||
make_tx_summary(logs, logs2)
|
||||
elif cmd == "correl":
|
||||
from scipy import stats
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue