diff options
| -rw-r--r-- | allocbench/benchmark.py | 38 | ||||
| -rw-r--r-- | allocbench/globalvars.py | 26 | ||||
| -rw-r--r-- | allocbench/plots.py | 4 | ||||
| -rwxr-xr-x | bench.py | 5 | ||||
| -rwxr-xr-x | summarize.py | 3 |
5 files changed, 24 insertions, 52 deletions
diff --git a/allocbench/benchmark.py b/allocbench/benchmark.py index 90d0572..2ef77f7 100644 --- a/allocbench/benchmark.py +++ b/allocbench/benchmark.py @@ -38,7 +38,6 @@ from allocbench.directories import (get_allocbench_benchmark_src_dir, get_allocbench_benchmark_build_dir, get_allocbench_build_dir) import allocbench.facter as facter -import allocbench.globalvars from allocbench.util import (print_status, find_cmd, prefix_cmd_with_abspath, run_cmd, get_logger) @@ -188,8 +187,6 @@ class Benchmark: """Initialize a benchmark with default members if they aren't set already""" self.name = name - self.allocators = copy.deepcopy(allocbench.globalvars.ALLOCATORS) - # Set result_dir if not hasattr(self, "result_dir"): res_dir = get_current_result_dir() @@ -207,13 +204,12 @@ class Benchmark: default_results = { "args": self.args, - "allocators": self.allocators, + "allocators": None, "facts": { "libcs": {}, "versions": {} } } - default_results.update({alloc: {} for alloc in self.allocators}) if not hasattr(self, "results"): self.results = default_results @@ -521,9 +517,23 @@ class Benchmark: for server in self.servers: self.shutdown_server(server) - def run(self, runs=3): + def expand_invalid_results(self, valid_result, allocators): + """Expand each empty measurement with the fields from a valid one and NaN""" + for allocator in allocators: + for perm in self.iterate_args(): + for i, measure in enumerate(self.results[allocator][perm]): + if not measure: + self.results[allocator][perm][i] = { + k: np.NaN + for k in valid_result + } + + def run(self, allocators: Dict[str, Dict[str, str]], runs=3): """generic run implementation""" + self.results["allocators"] = copy.deepcopy(allocators) + self.results.update({alloc: {} for alloc in allocators}) + # check if we are allowed to use perf if self.measure_cmd.startswith("perf"): Benchmark.is_perf_allowed() @@ -536,13 +546,12 @@ class Benchmark: self.results["facts"]["runs"] = runs - total_executions = len(list(self.iterate_args())) * len( - self.allocators) + total_executions = len(list(self.iterate_args())) * len(allocators) for run in range(1, runs + 1): print_status(run, ". run", sep='') i = 0 - for alloc_name, alloc in self.allocators.items(): + for alloc_name, alloc in allocators.items(): if alloc_name not in self.results: self.results[alloc_name] = {} @@ -683,15 +692,8 @@ class Benchmark: f"{os.pathsep}{self.build_dir}", "") # expand invalid results - if valid_result != {}: - for allocator in self.allocators: - for perm in self.iterate_args(): - for i, measure in enumerate(self.results[allocator][perm]): - if measure == {}: - self.results[allocator][perm][i] = { - k: np.NaN - for k in valid_result - } + if valid_result: + self.expand_invalid_results(valid_result, allocators) self.calc_desc_statistics() diff --git a/allocbench/globalvars.py b/allocbench/globalvars.py deleted file mode 100644 index 0640dc7..0000000 --- a/allocbench/globalvars.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> -# -# This file is part of allocbench. -# -# allocbench is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# allocbench is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with allocbench. If not, see <http://www.gnu.org/licenses/>. -"""Global variables for allocbench - -ALLOCATORS: Dict holding the allocators to compare -""" - -from typing import Dict - -from allocbench.allocator import Allocator - -ALLOCATORS: Dict[str, Allocator] = {} diff --git a/allocbench/plots.py b/allocbench/plots.py index 80e820b..1747d95 100644 --- a/allocbench/plots.py +++ b/allocbench/plots.py @@ -376,9 +376,9 @@ def plot(bench, Directory where the plot should be saved. If not provided defaults to the current working directory. - file_ext : str, optional, default=:rc:`allocbench.globalvars.SUMMARY_FILE_EXT` + file_ext : str, optional, default=:rc:`allocbench.plots.SUMMARY_FILE_EXT` File extension of the saved plot. If not provided defaults to the - value of :rc:`allocbench.globalvars.SUMMARY_FILE_EXT` + value of :rc:`allocbench.plots.SUMMARY_FILE_EXT` """ @@ -144,7 +144,6 @@ def main(): # allocators to benchmark allocators = collect_allocators(args.allocators) - allocbench.globalvars.ALLOCATORS = allocators logger.info(f"Allocators: {'%s, ' * (len(allocators) - 1)}%s", *allocators.keys()) @@ -203,14 +202,14 @@ def main(): analyze_bench(bench) if args.analyze_allocators: - analyze_allocators(bench, allocbench.globalvars.ALLOCATORS) + analyze_allocators(bench, allocators) if args.runs > 0: print_status("Running", bench.name, "...") start_time = datetime.datetime.now() bench.results['facts']['start-time'] = start_time.isoformat() try: - bench.run(runs=args.runs) + bench.run(allocators, runs=args.runs) except Exception: #pylint: disable=broad-except # Reset cwd os.chdir(cwd) diff --git a/summarize.py b/summarize.py index 545d06c..9bf0bf5 100755 --- a/summarize.py +++ b/summarize.py @@ -24,7 +24,6 @@ import sys from allocbench.directories import set_current_result_dir, get_current_result_dir import allocbench.facter as facter -import allocbench.globalvars import allocbench.benchmark import allocbench.util from allocbench.util import print_status, set_verbosity, print_license_and_exit, get_logger @@ -62,8 +61,6 @@ def specific_summary(bench, sum_dir, allocators): if value["color"] is None: value["color"] = avail_colors.pop() - allocbench.globalvars.ALLOCATORS = allocators - bench.summary() bench.results["allocators"] = old_allocs os.chdir("..") |
