realistic
This commit is contained in:
parent
aa3bb124fc
commit
e184b429ed
6 changed files with 256 additions and 28 deletions
125
plots.py
125
plots.py
|
|
@ -118,9 +118,6 @@ def gnuplot_stacked_histogram(**kwargs):
|
|||
titleline = ""
|
||||
if kwargs["maketitle"]:
|
||||
titleline = 'set title font "CMU Sans Serif,12" "{object_title} by {criterion_title} ({record}, {side}{machine}) ({unit})"'.format(**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
|
||||
|
|
@ -146,10 +143,63 @@ set term pict2e font ",10"
|
|||
set output "{plots_dir}/{object}_by_{criterion}_{side}_{record}.tex"
|
||||
set key font ",10" spacing 0.8
|
||||
replot
|
||||
""".format(plots_dir=PLOTS_DIR, cluster=cluster, titleline=titleline, **kwargs).replace("aws_lc", "aws-lc"))
|
||||
""".format(plots_dir=PLOTS_DIR, titleline=titleline, **kwargs).replace("aws_lc", "aws-lc"))
|
||||
f.close()
|
||||
os.system("gnuplot {plots_dir}/{object}_by_{criterion}_{side}_{record}.gnuplot".format(plots_dir=PLOTS_DIR, **kwargs))
|
||||
|
||||
def gnuplot_stacked_histogram_grouped(**kwargs):
|
||||
if "machine" in kwargs and kwargs["machine"] != None:
|
||||
kwargs["machine"] = ", " + kwargs["machine"]
|
||||
else:
|
||||
kwargs["machine"] = ""
|
||||
titleline = ""
|
||||
if kwargs["maketitle"]:
|
||||
titleline = 'set title font "CMU Sans Serif,12" "{object_title} by {criterion_title} ({record}, {side}{machine}) ({unit})"'.format(**kwargs)
|
||||
cluster = ""
|
||||
cluster_i = 0
|
||||
for group in kwargs["groups"]:
|
||||
if cluster_i > 0:
|
||||
cluster += ",\\\n\t"
|
||||
cluster += f' newhistogram "{group}"'
|
||||
for i in range(3, kwargs["nb_functions"]+2):
|
||||
if i == 3:
|
||||
cluster += ',\\\n\t "{plots_dir}/{object}_by_{criterion}_{side}_{record}_{group}.dat"'.format(group=group, plots_dir=PLOTS_DIR, **kwargs)
|
||||
else:
|
||||
cluster += ',\\\n\t ""'
|
||||
if cluster_i == 0:
|
||||
cluster += f' using {i}:xticlabels(2) title col'
|
||||
else:
|
||||
cluster += f' using {i}:xticlabels(2) notitle'
|
||||
cluster_i += 1
|
||||
f = open("{plots_dir}/{object}_by_{criterion}_{side}_{record}_{group_by}.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}_{group_by}.png"
|
||||
set boxwidth 0.9 absolute
|
||||
set style fill solid 1.0 border lt -1
|
||||
set style histogram rowstacked gap 0
|
||||
set style data histograms
|
||||
{titleline}
|
||||
set xtics border in scale 0,0 nomirror noenhanced rotate by 30 right
|
||||
set lmargin 9
|
||||
set rmargin 1
|
||||
set bmargin 5
|
||||
set tmargin 2.5
|
||||
set key fixed left top vertical Left noenhanced nobox invert reverse opaque
|
||||
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{cluster}
|
||||
#set term cairolatex pdf
|
||||
set term pict2e font ",10"
|
||||
set output "{plots_dir}/{object}_by_{criterion}_{side}_{record}_{group_by}.tex"
|
||||
set key font ",10" spacing 0.8
|
||||
replot
|
||||
""".format(plots_dir=PLOTS_DIR, cluster=cluster, titleline=titleline, **kwargs).replace("aws_lc", "aws-lc"))
|
||||
f.close()
|
||||
os.system("gnuplot {plots_dir}/{object}_by_{criterion}_{side}_{record}_{group_by}.gnuplot".format(plots_dir=PLOTS_DIR, **kwargs))
|
||||
|
||||
def make_log_plot(logs, exp, criterion, side, obj, record, machine=None, version=None, maketitle=True):
|
||||
f = open(f"/dev/shm/plots/{obj}_by_{criterion}_{side}_{record}.dat", "w")
|
||||
ciphers = {}
|
||||
|
|
@ -283,6 +333,64 @@ def make_profile_plot(logs, exp, criterion, side, record, no_flamegraph=False, m
|
|||
maketitle=maketitle
|
||||
)
|
||||
|
||||
def make_profile_plot_grouped(logs, exp, criterion, side, record, group_by, no_flamegraph=False, machine=None, version=None, maketitle=False):
|
||||
runs = []
|
||||
functions = []
|
||||
files = {}
|
||||
|
||||
for log in logs:
|
||||
if version != None and VER_LABEL[log["cipher"]] != version:
|
||||
continue
|
||||
if log["exp"] == exp and log["record"] == record and log["side"] == side and log["tls"] == "1":
|
||||
svg_filename = log["prof"] + ".svg"
|
||||
if not no_flamegraph:
|
||||
os.system("flamegraph --perfdata {} -o {}".format(log["prof"], svg_filename))
|
||||
try:
|
||||
profile_results = profile.extract_from_file(svg_filename)
|
||||
except FileNotFoundError:
|
||||
print(f"Cannot read {svg_filename}")
|
||||
continue
|
||||
print(profile_results)
|
||||
for function in profile_results:
|
||||
if function not in functions:
|
||||
functions.append(function)
|
||||
log_group = log[group_by]
|
||||
runs.append({
|
||||
criterion: log[COL[criterion]],
|
||||
"impl": log["impl"],
|
||||
"group": log_group,
|
||||
"functions": profile_results,
|
||||
})
|
||||
if log_group not in files:
|
||||
files[log_group] = open(f"/dev/shm/plots/profile_by_{criterion}_{side}_{record}_{log_group}.dat", "w")
|
||||
for group in files:
|
||||
files[group].write("{} {} {}\n".format(group_by, criterion, " ".join(functions)))
|
||||
for run in runs:
|
||||
files[run["group"]].write("{} {} {}\n".format(
|
||||
run["group"],
|
||||
ALG_LABEL[run[criterion]],
|
||||
" ".join([
|
||||
str(run["functions"][function][0])
|
||||
for function in functions
|
||||
]),
|
||||
))
|
||||
for group in files:
|
||||
files[group].close()
|
||||
gnuplot_stacked_histogram_grouped(
|
||||
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,
|
||||
machine=machine,
|
||||
maketitle=maketitle,
|
||||
group_by=group_by,
|
||||
groups=[group for group in files]
|
||||
)
|
||||
|
||||
# Are CPU and energy proportional
|
||||
def make_linear_regression(logs):
|
||||
idle_cpu = None
|
||||
|
|
@ -418,9 +526,12 @@ if __name__ == "__main__":
|
|||
elif cmd == "prof":
|
||||
for side in ["client", "server"]:
|
||||
for record in records:
|
||||
make_profile_plot(logs, "impl-cipher-ver", "cipher", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot(logs, "impl-cert-ver", "cert", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
make_profile_plot(logs, "impl-kex-ver", "kex", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
#make_profile_plot(logs, "impl-cipher-ver", "cipher", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
#make_profile_plot(logs, "impl-cert-ver", "cert", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
#make_profile_plot(logs, "impl-kex-ver", "kex", side, record, no_flamegraph=no_flamegraph, machine=machine, maketitle=maketitle, version="1.3")
|
||||
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 == "correl":
|
||||
from scipy import stats
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue