aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-03-06 13:48:50 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-03-06 13:48:50 +0100
commit10b5cf36b30f3aefdf441a8b62f96218294c5fdc (patch)
treee0a89f7b75dad0c12a447ccf0f59c391199cc575
parent8fde3923932fa55979661572b82ffd25b1c33f87 (diff)
downloadallocbench-10b5cf36b30f3aefdf441a8b62f96218294c5fdc.tar.gz
allocbench-10b5cf36b30f3aefdf441a8b62f96218294c5fdc.zip
save facts and rstore them on load
-rwxr-xr-xbench.py28
-rw-r--r--src/globalvars.py3
2 files changed, 28 insertions, 3 deletions
diff --git a/bench.py b/bench.py
index 1db8ca0..17cddbe 100755
--- a/bench.py
+++ b/bench.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
import argparse
+import atexit
import datetime
import importlib
import os
+import pickle
import subprocess
import src.facter
@@ -28,6 +30,14 @@ parser.add_argument("-rd", "--resultdir", help="directory where all results go",
parser.add_argument("--license", help="print license info and exit", action='store_true')
+"""Run tasks on exit"""
+def epilog():
+ if os.listdir(src.globalvars.resdir) == []:
+ os.removedirs(src.globalvars.resdir)
+ else:
+ with open(os.path.join(src.globalvars.resdir, "facts.save"), "wb") as f:
+ pickle.dump(src.globalvars.facts, f)
+
def main():
args = parser.parse_args()
if args.license:
@@ -35,6 +45,8 @@ def main():
print("License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>")
return
+ atexit.register(epilog)
+
# Set global verbosity
# quiet | -1: Don't output to stdout
# default | 0: Only print status and errors
@@ -81,17 +93,27 @@ def main():
print_info("Allocators:", *src.globalvars.allocators.keys())
+ # Load facts
+ if args.load:
+ with open(os.path.join(args.load, "facts.save"), "rb") as f:
+ old_facts = pickle.load(f)
+ if old_facts != src.globalvars.facts and args.runs > 0:
+ print_error("Can't combine benchmarks with different facts")
+ print_error("Aborting.")
+ exit(1)
+ else:
+ src.globalvars.facts = old_facts
+
# Create result directory if we save or summarize results
need_resultdir = not (args.nosum and args.dont_save)
if need_resultdir:
if args.resultdir:
resdir = os.path.join(args.resultdir)
else:
- # TODO use saved hostname
- if args.load and args.runs < 2:
- pass
resdir = os.path.join("results", src.globalvars.facts["hostname"],
datetime.datetime.now().strftime("%Y-%m-%dT%H:%M"))
+ # make resdir globally available
+ src.globalvars.resdir = resdir
try:
print_info2("Creating result dir:", resdir)
os.makedirs(resdir)
diff --git a/src/globalvars.py b/src/globalvars.py
index 0dcfd2c..c897786 100644
--- a/src/globalvars.py
+++ b/src/globalvars.py
@@ -15,3 +15,6 @@ allocators_file = None
"""Path of the build directory"""
builddir = os.path.join(os.getcwd(), "build")
+
+"""Directory were the benchmark results are stored"""
+resdir = None