From 68056c96b0e69b63e3890d387be4a1831dc85da3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 23 Jan 2020 18:13:19 +0100 Subject: add simple pgfplot function --- src/benchmark.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/benchmark.py b/src/benchmark.py index d234755..c572618 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -973,3 +973,45 @@ class Benchmark: print("\\end{tabular}", file=f) print("\\end{document}", file=f) + + def pgfplot_linear(self, perms, xval, yval, ylabel="'y-label'", xlabel="'x-label'", + title="'default title'", postfix="", sumdir="", scale=None): + + allocators = self.results["allocators"] + perms = list(perms) + title = eval(title) + s =\ +"""\\documentclass{standalone} +\\usepackage{pgfplots} +""" + + for alloc in allocators: + s += f"\\begin{{filecontents*}}{{{alloc}.dat}}\n" + for i, perm in enumerate(perms): + x = self._eval_with_stat(xval, alloc, perm, "mean") + y = self._eval_with_stat(yval, alloc, perm, "mean") + s += f"{x} {y}\n" + s += "\\end{filecontents*}\n" + + s +=\ +f""" +\\begin{{document}} +\\begin{{tikzpicture}} +\\begin{{axis}}[ +\ttitle={{{title}}}, +\txlabel={{{eval(xlabel)}}}, +\tylabel={{{eval(ylabel)}}}, +] +""" + + for alloc in allocators: + # s += f"\\addplot [color{i}] table {{{alloc_name}.dat}}" + s += f"\t\\addplot table {{{alloc}.dat}};\n" + + s +=\ +"""\\end{axis} +\\end{tikzpicture} +\\end{document}""" + + with open(os.path.join(sumdir, f"{self.name}.{postfix}.tex"), "w") as plot_file: + print(s, file=plot_file) -- cgit v1.2.3