Commit eda3df80 authored by Florian Fischer's avatar Florian Fischer
Browse files

add simple python script to generate boxplots

parent 66319fdc
Pipeline #66585 failed with stage
in 60 minutes and 1 second
#!/usr/bin/env python3
import yaml
import sys
def parse_data(stream):
"""Convert yamls string to dict"""
return yaml.safe_load(stream)
TIKZ_TEMPLATE = \
"""
\\documentclass[crop=false]{standalone}
\\usepackage{pgfplotstable}
\\pgfplotsset{compat=1.17}
\\usepgfplotslibrary{statistics}
\\begin{document}
\\begin{tikzpicture}
\\begin{axis}[
boxplot/draw direction=y,
legend columns=2,
area legend,
legend style={
font=\scriptsize,
draw=none,
fill=none,
at={(0.5,-0.1)},
anchor=north
},
]
$PLOTS$
\\end{axis}
\\end{tikzpicture}
\\end{document}
"""
PLOT_TEMPLATE = \
"""\\addplot+[
boxplot prepared={{
lower whisker={lower_whisker},
lower quartile={lower_quartile},
median={median},
average={mean},
upper quartile={upper_quartile},
upper whisker={upper_whisker},
}},
] coordinates{{}};
\\addlegendentry{{{syscall}}}
"""
def generate_boxplot(data):
plots = ''
for syscall, stats in data.items():
plots += PLOT_TEMPLATE.format(syscall=syscall.replace('_', '-'), **stats["nanos"])
return TIKZ_TEMPLATE.replace('$PLOTS$', plots)
if __name__ == '__main__':
if len(sys.argv) == 1:
_data = parse_data(sys.stdin)
else:
with open(sys.argv[1], 'r') as yaml_file:
_data = parse_data(yaml_file)
tikz = generate_boxplot(_data)
if len(sys.argv) > 2:
with open(sys.argv[2], 'w') as saveto:
print(tikz, file=saveto)
else:
print(tikz)
......@@ -109,8 +109,8 @@ void print_desc_stats(const char* name, const char* indentation, const uint64_t*
printf("%s%smean: %lu\n", indentation, indentation, mean);
printf("%s%svar: %lu\n", indentation, indentation, var);
printf("%s%sstd: %lu\n", indentation, indentation, std);
printf("%s%sprctl_25: %lu\n", indentation, indentation, prctl_25);
printf("%s%sprctl_75: %lu\n", indentation, indentation, prctl_75);
printf("%s%slower_quartile: %lu\n", indentation, indentation, prctl_25);
printf("%s%supper_quartile: %lu\n", indentation, indentation, prctl_75);
printf("%s%slower_whisker: %lu\n", indentation, indentation, lower_whisker);
printf("%s%supper_whisker: %lu\n", indentation, indentation, upper_whisker);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment