diff options
| -rw-r--r-- | src/allocator.py | 23 | ||||
| -rw-r--r-- | src/benchmark.py | 19 |
2 files changed, 18 insertions, 24 deletions
diff --git a/src/allocator.py b/src/allocator.py index 1ff29f3..7b76543 100644 --- a/src/allocator.py +++ b/src/allocator.py @@ -54,6 +54,17 @@ class Allocator: "color", "sources", "version", "patches", "prepare_cmds", "build_cmds" ] + binary_suffix = None + cmd_prefix = None + LD_PRELOAD = None + LD_LIBRARY_PATH = None + color = None + sources = None + version = None + patches = [] + prepare_cmds = [] + build_cmds = [] + def __init__(self, name, **kwargs): self.class_file = inspect.getfile(self.__class__) self.name = name @@ -61,18 +72,6 @@ class Allocator: self.dir = os.path.join(BUILDDIR, self.name) self.patchdir = os.path.join(os.path.splitext(self.class_file)[0]) - # members known by the base class - self.binary_suffix = self.binary_suffix if hasattr(self, "binary_suffix") else None - self.cmd_prefix = self.cmd_prefix if hasattr(self, "cmd_prefix") else None - self.LD_PRELOAD = self.LD_PRELOAD if hasattr(self, "LD_PRELOAD") else None - self.LD_LIBRARY_PATH = self.LD_LIBRARY_PATH if hasattr(self, "LD_LIBRARY_PATH") else None - self.color = self.color if hasattr(self, "color") else None - self.sources = self.sources if hasattr(self, "sources") else None - self.version = self.version if hasattr(self, "version") else None - self.patches = self.patches if hasattr(self, "patches") else [] - self.prepare_cmds = self.prepare_cmds if hasattr(self, "prepare_cmds") else [] - self.build_cmds = self.build_cmds if hasattr(self, "build_cmds") else [] - # Update attributes for attr, value in kwargs.items(): setattr(self, attr, value) diff --git a/src/benchmark.py b/src/benchmark.py index 905a11f..d234755 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -27,12 +27,12 @@ class Benchmark: # class member to remember if we are allowed to use perf perf_allowed = None - defaults = {"cmd": "false", - "args": {}, - "measure_cmd_csv": False, - "measure_cmd": "perf stat -x, -d", - "servers": [], - "allocators": copy.deepcopy(src.globalvars.allocators)} + cmd = "false" + args = {} + measure_cmd_csv = False + measure_cmd = "perf stat -x, -d" + servers = [] + allocators = copy.deepcopy(src.globalvars.allocators) @staticmethod def terminate_subprocess(proc, timeout=5): @@ -104,11 +104,6 @@ class Benchmark: """Initialize a benchmark with default members if they aren't set already""" self.name = name - # Set default values - for k in Benchmark.defaults: - if not hasattr(self, k): - setattr(self, k, Benchmark.defaults[k]) - # Set result_dir if not hasattr(self, "result_dir"): self.result_dir = os.path.abspath(os.path.join(src.globalvars.resdir or "", @@ -486,7 +481,7 @@ class Benchmark: break # parse perf output if available - if self.measure_cmd == self.defaults["measure_cmd"] or self.measure_cmd_csv: + if self.measure_cmd == Benchmark.measure_cmd or self.measure_cmd_csv: csvreader = csv.reader(res.stderr.splitlines(), delimiter=',') for row in csvreader: |
