aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-03-21 16:30:49 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-03-21 17:33:44 +0100
commit9165e1dafa8a200073098ec34e73a76646bec9e2 (patch)
treea21cf7f0544d9dcbb16feacbe6632c482503cf14
parent4c9c8919294ab72cfa7ea310c4c9bc384fa0828e (diff)
downloadallocbench-9165e1dafa8a200073098ec34e73a76646bec9e2.tar.gz
allocbench-9165e1dafa8a200073098ec34e73a76646bec9e2.zip
use exceptions to indicate an error
-rwxr-xr-xbench.py63
1 files changed, 34 insertions, 29 deletions
diff --git a/bench.py b/bench.py
index bbea7c3..5787025 100755
--- a/bench.py
+++ b/bench.py
@@ -7,6 +7,7 @@ import importlib
import os
import pickle
import subprocess
+import traceback
import src.facter
import src.globalvars
@@ -134,46 +135,50 @@ def main():
# TODO load all results at once
+ cwd = os.getcwd()
for bench in benchmarks:
- if args.benchmarks and not bench in args.benchmarks:
- continue
+ try:
+ if args.benchmarks and not bench in args.benchmarks:
+ continue
- bench = eval("importlib.import_module('src.{0}').{0}".format(bench))
+ bench = eval("importlib.import_module('src.{0}').{0}".format(bench))
- if args.load:
- bench.load(path=args.load)
+ if args.load:
+ bench.load(path=args.load)
- if args.runs > 0:
- print_status("Preparing", bench.name, "...")
- if not bench.prepare():
- print_error("Preparing", bench.name, "failed!")
- continue
+ if args.runs > 0:
+ print_status("Preparing", bench.name, "...")
+ bench.prepare()
- if not bench.run(runs=args.runs):
- continue
+ if not bench.run(runs=args.runs):
+ continue
- if need_resultdir:
- print_info2("Changing cwd to:", resdir)
- old_cwd = os.getcwd()
- os.chdir(resdir)
+ if need_resultdir:
+ print_info2("Changing cwd to:", resdir)
+ os.chdir(resdir)
- if not args.dont_save:
- bench.save()
+ if not args.dont_save:
+ bench.save()
- if not args.nosum:
- try:
+ if not args.nosum:
os.mkdir(bench.name)
- except FileExistsError:
- pass
- os.chdir(bench.name)
- print_status("Summarizing", bench.name, "...")
- bench.summary()
+ os.chdir(bench.name)
+ print_status("Summarizing", bench.name, "...")
+ bench.summary()
+
+ os.chdir(cwd)
- os.chdir(old_cwd)
+ if args.runs > 0 and hasattr(bench, "cleanup"):
+ print_status("Cleaning up", bench.name, "...")
+ bench.cleanup()
- if args.runs > 0 and hasattr(bench, "cleanup"):
- print_status("Cleaning up", bench.name, "...")
- bench.cleanup()
+ except Exception:
+ # Reset cwd
+ os.chdir(cwd)
+
+ print_error(traceback.format_exc())
+ print_error("Skipping", bench.name, "!")
+ continue
if __name__ == "__main__":
main()