aboutsummaryrefslogtreecommitdiff
path: root/summarize.py
diff options
context:
space:
mode:
Diffstat (limited to 'summarize.py')
-rwxr-xr-xsummarize.py55
1 files changed, 42 insertions, 13 deletions
diff --git a/summarize.py b/summarize.py
index 6f575a9..109c399 100755
--- a/summarize.py
+++ b/summarize.py
@@ -1,23 +1,44 @@
#!/usr/bin/env python3
+# 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/>.
+
+"""Summarize the results of an allocbench run"""
+
import argparse
import importlib
import os
import pickle
+import sys
import src.globalvars
from src.util import print_status, print_debug, print_error
+from src.util import print_license_and_exit
def specific_summary(bench, allocators):
"""Summarize bench in PWD for allocators"""
old_allocs = bench.results["allocators"]
- new_allocs = {k: v for k, v in old_allocs.items() if k in allocators}
+ allocs_in_set = {k: v for k, v in old_allocs.items() if k in allocators}
- bench.results["allocators"] = new_allocs
+ bench.results["allocators"] = allocs_in_set
# set colors
- explicit_colors = [v["color"] for k, v in allocators.items()
+ explicit_colors = [v["color"] for k, v in allocs_in_set.items()
if v["color"] is not None]
print_debug("Explicit colors:", explicit_colors)
@@ -26,7 +47,7 @@ def specific_summary(bench, allocators):
if color not in explicit_colors]
print_debug("available colors:", avail_colors)
- for _, value in allocators.items():
+ for _, value in allocs_in_set.items():
if value["color"] is None:
value["color"] = avail_colors.pop()
@@ -65,12 +86,26 @@ def bench_sum(bench):
def main():
+ if "--license" in sys.argv:
+ print_license_and_exit()
+
parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets")
parser.add_argument("results", help="path to results", type=str)
+ parser.add_argument("--license", help="print license info and exit", action='store_true')
parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+')
parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+')
args = parser.parse_args()
+
+ if not os.path.isdir(args.results):
+ print_error(f"{args.results} is no directory")
+ exit(1)
+
+ if not os.path.isfile(os.path.join(args.results, "facts.save")):
+ print_error(f"{args.results} is no valid allocbench result it misses facts.save")
+ exit(1)
+
+ src.globalvars.resdir = args.results
os.chdir(args.results)
# Load facts
@@ -83,23 +118,17 @@ def main():
if args.exclude_benchmarks and benchmark in args.exclude_benchmarks:
continue
- try:
- bench = importlib.import_module(f"src.benchmarks.{benchmark}")
- except ModuleNotFoundError:
- print_error(f"Could not import {benchmark}")
- print_error(f"Skipping {benchmark}.")
+ bench_module = importlib.import_module(f"src.benchmarks.{benchmark}")
- if not hasattr(bench, benchmark):
+ if not hasattr(bench_module, benchmark):
print_error(f"{benchmark} has no member {benchmark}")
print_error(f"Skipping {benchmark}.")
- bench = getattr(bench, benchmark)
+ bench = getattr(bench_module, benchmark)
try:
bench.load()
except FileNotFoundError:
- print_error(f"Could not load {benchmark}")
- print_error(f"Skipping {benchmark}.")
continue
print_status(f"Summarizing {bench.name} ...")