aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmerge.py (renamed from scripts/merge_saves.py)30
-rwxr-xr-xscripts/bench_sum.py89
-rwxr-xr-xsummarize.py113
3 files changed, 125 insertions, 107 deletions
diff --git a/scripts/merge_saves.py b/merge.py
index 7599a1e..935e809 100755
--- a/scripts/merge_saves.py
+++ b/merge.py
@@ -1,23 +1,17 @@
#!/usr/bin/env python3
import argparse
-import inspect
import os
import pickle
-import sys
-
-currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
-parentdir = os.path.dirname(currentdir)
-sys.path.insert(0, parentdir)
-
-parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets")
-parser.add_argument("src", help="path to results which should be merged into dest", type=str)
-parser.add_argument("dest", help="path to results in which src should be merged", type=str)
-parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+')
-parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+')
def main():
+ parser = argparse.ArgumentParser(description="Merge to allocbench results")
+ parser.add_argument("src", help="results which should be merged into dest", type=str)
+ parser.add_argument("dest", help="results in which src should be merged", type=str)
+ 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()
for src_save in os.listdir(args.src):
@@ -37,11 +31,11 @@ def main():
print("Can't merge", src_save, "because", os.path.basename(src_save), "not in", args.dest)
continue
- with open(src_save, "rb") as f:
- src_results = pickle.load(f)
+ with open(src_save, "rb") as src_file:
+ src_results = pickle.load(src_file)
- with open(dest_save, "rb") as f:
- dest_results = pickle.load(f)
+ with open(dest_save, "rb") as dest_file:
+ dest_results = pickle.load(dest_file)
for alloc in src_results["allocators"]:
if alloc in dest_results["allocators"]:
@@ -53,8 +47,8 @@ def main():
dest_results[alloc] = src_results[alloc]
dest_results["stats"][alloc] = src_results["stats"][alloc]
- with open(dest_save, "wb") as f:
- pickle.dump(dest_results, f)
+ with open(dest_save, "wb") as result_file:
+ pickle.dump(dest_results, result_file)
if __name__ == "__main__":
diff --git a/scripts/bench_sum.py b/scripts/bench_sum.py
deleted file mode 100755
index e34ccad..0000000
--- a/scripts/bench_sum.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-import importlib
-import inspect
-import os
-import pickle
-import sys
-
-currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
-parentdir = os.path.dirname(currentdir)
-sys.path.insert(0,parentdir)
-
-import src.globalvars
-
-sets = {"glibcs": ["glibc", "glibc-noThreadCache", "glibc-noFalsesharing",
- "glibc-noFalsesharingClever"],
- "tcmalloc": ["TCMalloc", "TCMalloc-NoFalsesharing"],
- "nofs": ["glibc", "glibc-noFalsesharing", "glibc-noFalsesharingClever",
- "TCMalloc", "TCMalloc-NoFalsesharing"],
- "ba" : ["glibc", "TCMalloc", "jemalloc", "Hoard"],
- "industry" : ["glibc", "llalloc", "TCMalloc", "jemalloc", "tbbmalloc", "mimalloc"],
- "research" : ["scalloc", "SuperMalloc", "Mesh", "Hoard", "snmalloc"]}
-
-
-def specific_summary(bench, allocators):
- old_allocs = bench.results["allocators"]
- new_allocs = {k: v for k, v in old_allocs.items() if k in allocators}
-
- bench.results["allocators"] = new_allocs
- bench.summary()
- bench.results["allocators"] = old_allocs
-
-
-def bench_sum(bench, sets):
- os.makedirs(bench.name)
- os.chdir(bench.name)
-
- os.mkdir("all")
- os.chdir("all")
- bench.summary()
- os.chdir("..")
-
- for s in sets:
- os.mkdir(s)
- os.chdir(s)
- specific_summary(bench, sets[s])
- os.chdir("..")
-
- os.chdir("..")
-
-
-parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets")
-parser.add_argument("results", help="path to results", type=str)
-parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+')
-parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+')
-
-def main():
- args = parser.parse_args()
- os.chdir(args.results)
-
- # Load facts
- with open("facts.save", "rb") as f:
- src.globalvars.facts = pickle.load(f)
-
- for b in src.globalvars.benchmarks:
- if args.benchmarks and not b in args.benchmarks:
- continue
- if args.exclude_benchmarks and b in args.exclude_benchmarks:
- continue
-
- bench = eval("importlib.import_module('src.benchmarks.{0}').{0}".format(b))
- try:
- print(f"{bench.name} ...", end="", flush=True)
- bench.load()
- except FileNotFoundError as e:
- print(" No data available")
- continue
-
- try:
- bench_sum(bench, sets)
- except FileExistsError as e:
- print(e, end="")
-
- print()
-
-
-if __name__ == "__main__":
- main()
diff --git a/summarize.py b/summarize.py
new file mode 100755
index 0000000..6f575a9
--- /dev/null
+++ b/summarize.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+
+import argparse
+import importlib
+import os
+import pickle
+
+import src.globalvars
+from src.util import print_status, print_debug, print_error
+
+
+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}
+
+ bench.results["allocators"] = new_allocs
+
+ # set colors
+ explicit_colors = [v["color"] for k, v in allocators.items()
+ if v["color"] is not None]
+ print_debug("Explicit colors:", explicit_colors)
+
+ cycle_list = ["C" + str(i) for i in range(0, 16)]
+ avail_colors = [color for color in cycle_list
+ if color not in explicit_colors]
+ print_debug("available colors:", avail_colors)
+
+ for _, value in allocators.items():
+ if value["color"] is None:
+ value["color"] = avail_colors.pop()
+
+ src.globalvars.allocators = allocators
+
+ bench.summary()
+ bench.results["allocators"] = old_allocs
+
+
+def bench_sum(bench):
+ """Create a summary of bench for each set of allocators"""
+ sets = {"glibcs": ["glibc", "glibc-noThreadCache", "glibc-noFalsesharing",
+ "glibc-noFalsesharingClever"],
+ "tcmalloc": ["TCMalloc", "TCMalloc-NoFalsesharing"],
+ "nofs": ["glibc", "glibc-noFalsesharing", "glibc-noFalsesharingClever",
+ "TCMalloc", "TCMalloc-NoFalsesharing"],
+ "ba" : ["glibc", "TCMalloc", "jemalloc", "Hoard"],
+ "industry" : ["glibc", "llalloc", "TCMalloc", "jemalloc", "tbbmalloc", "mimalloc"],
+ "research" : ["scalloc", "SuperMalloc", "Mesh", "Hoard", "snmalloc"]}
+
+ os.makedirs(bench.name)
+ os.chdir(bench.name)
+
+ os.mkdir("all")
+ os.chdir("all")
+ bench.summary()
+ os.chdir("..")
+
+ for set_name in sets:
+ os.mkdir(set_name)
+ os.chdir(set_name)
+ specific_summary(bench, sets[set_name])
+ os.chdir("..")
+
+ os.chdir("..")
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Summarize allocbench results in allocator sets")
+ parser.add_argument("results", help="path to results", type=str)
+ 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()
+ os.chdir(args.results)
+
+ # Load facts
+ with open("facts.save", "rb") as f:
+ src.globalvars.facts = pickle.load(f)
+
+ for benchmark in src.globalvars.benchmarks:
+ if args.benchmarks and not benchmark in args.benchmarks:
+ continue
+ 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}.")
+
+ if not hasattr(bench, benchmark):
+ print_error(f"{benchmark} has no member {benchmark}")
+ print_error(f"Skipping {benchmark}.")
+
+ bench = getattr(bench, 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} ...")
+ try:
+ bench_sum(bench)
+ except FileExistsError as e:
+ print(e)
+
+
+if __name__ == "__main__":
+ main()