Profile graphs
This commit is contained in:
parent
0335dac6d4
commit
a81a01f394
5 changed files with 115 additions and 56 deletions
99
plots.py
99
plots.py
|
|
@ -1,4 +1,5 @@
|
|||
import os, sys
|
||||
import profile
|
||||
|
||||
# Nice labels for algorithms of all kinds
|
||||
ALG_LABEL = {
|
||||
|
|
@ -30,7 +31,8 @@ VER_LABEL = {
|
|||
# Titles for measured quantities
|
||||
OBJ_TITLE = {
|
||||
"cpu": "CPU time",
|
||||
"energy": "energy consumption"
|
||||
"energy": "energy consumption",
|
||||
"profile": "time profile",
|
||||
}
|
||||
# Logfile column names
|
||||
COL = {
|
||||
|
|
@ -43,7 +45,8 @@ COL = {
|
|||
# Physical units by object
|
||||
UNIT = {
|
||||
"cpu": "s",
|
||||
"energy": "W"
|
||||
"energy": "W",
|
||||
"profile": "samples",
|
||||
}
|
||||
# Titles for criteria
|
||||
CRITERION_TITLE = {
|
||||
|
|
@ -83,7 +86,31 @@ plot \
|
|||
f.close()
|
||||
os.system("gnuplot {plots_dir}/{object}_by_{criterion}_{side}_{record}.gnuplot".format(plots_dir=PLOTS_DIR, **kwargs))
|
||||
|
||||
def make_plot(logs, exp, criterion, side, obj, record):
|
||||
def gnuplot_stacked_histogram(**kwargs):
|
||||
cluster = ""
|
||||
#for i in range(kwargs["nb_impls"]-1):
|
||||
# cluster += """, "" using {}:xticlabels(1) title col""".format(i+4)
|
||||
f = open("{plots_dir}/{object}_by_{criterion}_{side}_{record}.gnuplot".format(plots_dir=PLOTS_DIR, **kwargs), "w")
|
||||
f.write("""\
|
||||
set terminal pngcairo enhanced font "CMU Sans Serif,11" fontscale 1.0 size 800, 600
|
||||
set output "{plots_dir}/{object}_by_{criterion}_{side}_{record}.png"
|
||||
set boxwidth 0.9 absolute
|
||||
set style fill solid 1.0 border lt -1
|
||||
set style histogram rowstacked
|
||||
set style data histograms
|
||||
set title font "CMU Sans Serif,12" "{object_title} by {criterion_title} ({record}, {side} side) ({unit})"
|
||||
set xtics border in scale 0,0 nomirror noenhanced rotate by -15 autojustify
|
||||
set key fixed right top vertical Right noenhanced autotitle nobox invert
|
||||
set colorbox vertical origin screen 0.9, 0.2 size screen 0.05, 0.6 front noinvert bdefault
|
||||
set xrange [ * : * ] noreverse writeback
|
||||
set yrange [ 0 : * ]
|
||||
set grid y lt 1 lw .75 lc "gray"
|
||||
plot for [i=2:{nb_functions}] "{plots_dir}/{object}_by_{criterion}_{side}_{record}.dat" using i:xticlabels(1) title col
|
||||
""".format(plots_dir=PLOTS_DIR, cluster=cluster, **kwargs))
|
||||
f.close()
|
||||
os.system("gnuplot {plots_dir}/{object}_by_{criterion}_{side}_{record}.gnuplot".format(plots_dir=PLOTS_DIR, **kwargs))
|
||||
|
||||
def make_log_plot(logs, exp, criterion, side, obj, record):
|
||||
f = open(f"/dev/shm/plots/{obj}_by_{criterion}_{side}_{record}.dat", "w")
|
||||
ciphers = {}
|
||||
impls = []
|
||||
|
|
@ -102,9 +129,7 @@ def make_plot(logs, exp, criterion, side, obj, record):
|
|||
return
|
||||
|
||||
for log in logs:
|
||||
if log["exp"] != exp or log["record"] != record:
|
||||
continue
|
||||
elif log["setup"] == side:
|
||||
if log["exp"] == exp and log["record"] == record and log["setup"] == side:
|
||||
if log[COL[criterion]] not in ciphers:
|
||||
ciphers[log[COL[criterion]]] = {}
|
||||
ciphers[log[COL[criterion]]][log["impl"]] = float(log[COL[obj]]) - idle_val * float(log["time"])
|
||||
|
|
@ -125,8 +150,43 @@ def make_plot(logs, exp, criterion, side, obj, record):
|
|||
f.close()
|
||||
gnuplot_histogram(object=obj, criterion=criterion, side=side, object_title=OBJ_TITLE[obj], criterion_title=CRITERION_TITLE[criterion], unit=UNIT[obj], nb_impls=len(impls), record=record)
|
||||
|
||||
def make_profile_plot(logs, exp, criterion, side, record, no_flamegraph=False):
|
||||
f = open(f"/dev/shm/plots/profile_by_{criterion}_{side}_{record}.dat", "w")
|
||||
runs = []
|
||||
functions = []
|
||||
|
||||
for log in logs:
|
||||
if log["exp"] == exp and log["record"] == record and log["setup"] == side:
|
||||
svg_filename = log["prof"] + ".svg"
|
||||
if not no_flamegraph:
|
||||
os.system("flamegraph --perfdata {} -o {}".format(log["prof"], svg_filename))
|
||||
profile_results = profile.extract_from_file(svg_filename)
|
||||
print(profile_results)
|
||||
for function in profile_results:
|
||||
if function not in functions:
|
||||
functions.append(function)
|
||||
runs.append({
|
||||
criterion: log[COL[criterion]],
|
||||
"impl": log["impl"],
|
||||
"functions": profile_results,
|
||||
})
|
||||
f.write("{} {}\n".format(criterion, " ".join(functions)))
|
||||
for run in runs:
|
||||
f.write("\"{} {}({})\" {}\n".format(
|
||||
run["impl"],
|
||||
ALG_LABEL[run[criterion]],
|
||||
VER_LABEL[log["cipher"]],
|
||||
" ".join([
|
||||
str(run["functions"][function][0])
|
||||
for function in functions
|
||||
]),
|
||||
))
|
||||
f.close()
|
||||
gnuplot_stacked_histogram(object="profile", criterion=criterion, side=side, object_title=OBJ_TITLE["profile"], criterion_title=CRITERION_TITLE[criterion], unit=UNIT["profile"], record=record, nb_functions=len(functions)+1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
logfile_name = sys.argv[1]
|
||||
cmd = sys.argv[1]
|
||||
logfile_name = sys.argv[2]
|
||||
logfile = open(logfile_name, "r")
|
||||
lines = logfile.readlines()
|
||||
logfile.close()
|
||||
|
|
@ -146,11 +206,20 @@ if __name__ == "__main__":
|
|||
|
||||
os.makedirs("/dev/shm/plots", exist_ok=True)
|
||||
|
||||
for side in ["client", "server"]:
|
||||
for record in records:
|
||||
make_plot(logs, "impl-cipher-ver", "cipher", side, "cpu", record)
|
||||
make_plot(logs, "impl-cipher-ver", "cipher", side, "energy", record)
|
||||
make_plot(logs, "impl-cert-ver", "cert", side, "cpu", record)
|
||||
make_plot(logs, "impl-cert-ver", "cert", side, "energy", record)
|
||||
make_plot(logs, "impl-kex-ver", "kex", side, "cpu", record)
|
||||
make_plot(logs, "impl-kex-ver", "kex", side, "energy", record)
|
||||
no_flamegraph = "-f" in sys.argv
|
||||
|
||||
if cmd == "log":
|
||||
for side in ["client", "server"]:
|
||||
for record in records:
|
||||
make_log_plot(logs, "impl-cipher-ver", "cipher", side, "cpu", record)
|
||||
make_log_plot(logs, "impl-cipher-ver", "cipher", side, "energy", record)
|
||||
make_log_plot(logs, "impl-cert-ver", "cert", side, "cpu", record)
|
||||
make_log_plot(logs, "impl-cert-ver", "cert", side, "energy", record)
|
||||
make_log_plot(logs, "impl-kex-ver", "kex", side, "cpu", record)
|
||||
make_log_plot(logs, "impl-kex-ver", "kex", side, "energy", record)
|
||||
elif cmd == "prof":
|
||||
for side in ["client-local", "server-local"]:
|
||||
for record in records:
|
||||
make_profile_plot(logs, "impl-cipher-ver", "cipher", side, record, no_flamegraph=no_flamegraph)
|
||||
make_profile_plot(logs, "impl-cert-ver", "cert", side, record, no_flamegraph=no_flamegraph)
|
||||
make_profile_plot(logs, "impl-kex-ver", "kex", side, record, no_flamegraph=no_flamegraph)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue