diff options
| -rwxr-xr-x | bench.py | 11 | ||||
| -rw-r--r-- | src/benchmark.py | 4 | ||||
| -rw-r--r-- | src/common_targets.py | 48 | ||||
| -rw-r--r-- | src/mysql.py | 4 | ||||
| -rw-r--r-- | src/targets.py | 19 |
5 files changed, 34 insertions, 52 deletions
@@ -6,12 +6,14 @@ import importlib import os import src.facter +import src.targets benchmarks = ["loop", "mysql", "falsesharing", "dj_trace", "larson"] parser = argparse.ArgumentParser(description="benchmark memory allocators") parser.add_argument("-s", "--save", help="save benchmark results to disk", action='store_true') parser.add_argument("-l", "--load", help="load benchmark results from directory", type=str) +parser.add_argument("-t", "--targets", help="load target definitions from file", type=str) parser.add_argument("-r", "--runs", help="how often the benchmarks run", default=3, type=int) parser.add_argument("-v", "--verbose", help="more output", action='store_true') parser.add_argument("-b", "--benchmarks", help="benchmarks to run", nargs='+') @@ -27,9 +29,18 @@ def main(): print("Copyright (C) 2018-1029 Florian Fischer") print("License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>") return + if args.verbose: print(args) + if args.targets: + with open(args.targets, "r") as f: + g = {} + exec(f.read(), g) + src.targets.targets = g["targets"] + if args.verbose: + print("Targets:", src.targets.targets.keys()) + if args.save or not args.nosum and not (args.runs < 1 and not args.load): if args.resultdir: resdir = os.path.join(args.resultdir) diff --git a/src/benchmark.py b/src/benchmark.py index a0da6a0..4de05e3 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -9,7 +9,7 @@ import pickle import shutil import subprocess -from src.common_targets import common_targets +from src.targets import targets class Benchmark (object): @@ -20,7 +20,7 @@ class Benchmark (object): "measure_cmd" : "perf stat -x, -d", "analyse_cmd" : "memusage -p {} -t", "cmd" : "true", - "targets" : common_targets, + "targets" : targets, } def __init__(self): diff --git a/src/common_targets.py b/src/common_targets.py deleted file mode 100644 index 7a109a6..0000000 --- a/src/common_targets.py +++ /dev/null @@ -1,48 +0,0 @@ -import subprocess - -glibc_path_notc = "../glibc/glibc-install-notc/lib" - -library_path = "" -p = subprocess.run(["ldconfig", "-v"], stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) - -for l in p.stdout.splitlines(): - if not l.startswith('\t'): - library_path += l - -common_targets = { - "glibc" : { - "cmd_prefix" : "", - "binary_suffix" : "", - "LD_PRELOAD" : "", - "color" : "C1" - }, - "tcmalloc" : { - "cmd_prefix" : "", - "binary_suffix" : "", - "LD_PRELOAD" : "targets/libtcmalloc.so", - "color" : "C2" - }, - "jemalloc" : { - "cmd_prefix" : "", - "binary_suffix" : "", - "LD_PRELOAD" : "targets/libjemalloc.so", - "color" : "C3" - }, - "hoard" : { - "cmd_prefix" : "", - "binary_suffix" : "", - "LD_PRELOAD" : "targets/libhoard.so", - "color" : "C4" - }, - "glibc-notc" : { - "cmd_prefix" : glibc_path_notc+"/ld-linux-x86-64.so.2 " - + "--library-path " - + glibc_path_notc + ":" - + library_path, - "binary_suffix" : "-glibc-notc", - "LD_PRELOAD" : "", - "color" : "C5" - }, - } diff --git a/src/mysql.py b/src/mysql.py index 6d19a97..f9b75e2 100644 --- a/src/mysql.py +++ b/src/mysql.py @@ -10,7 +10,7 @@ from subprocess import PIPE from time import sleep from src.benchmark import Benchmark -from src.common_targets import common_targets +from src.targets import targets cwd = os.getcwd() @@ -30,7 +30,7 @@ class Benchmark_MYSQL( Benchmark ): self.descrition = """See sysbench documentation.""" # mysqld fails with hoard somehow - self.targets = copy.copy(common_targets) + self.targets = copy.copy(targets) if "hoard" in self.targets: del(self.targets["hoard"]) diff --git a/src/targets.py b/src/targets.py new file mode 100644 index 0000000..50fcab0 --- /dev/null +++ b/src/targets.py @@ -0,0 +1,19 @@ +targets = {"glibc" : { + "cmd_prefix" : "", + "binary_suffix" : "", + "LD_PRELOAD" : "", + "color" : "C1" + }, + "tcmalloc" : { + "cmd_prefix" : "", + "binary_suffix" : "", + "LD_PRELOAD" : "targets/libtcmalloc.so", + "color" : "C2" + }, + "jemalloc" : { + "cmd_prefix" : "", + "binary_suffix" : "", + "LD_PRELOAD" : "targets/libjemalloc.so", + "color" : "C3" + }, + } |
