diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-21 16:30:49 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-21 17:33:44 +0100 |
| commit | 9165e1dafa8a200073098ec34e73a76646bec9e2 (patch) | |
| tree | a21cf7f0544d9dcbb16feacbe6632c482503cf14 | |
| parent | 4c9c8919294ab72cfa7ea310c4c9bc384fa0828e (diff) | |
| download | allocbench-9165e1dafa8a200073098ec34e73a76646bec9e2.tar.gz allocbench-9165e1dafa8a200073098ec34e73a76646bec9e2.zip | |
use exceptions to indicate an error
| -rwxr-xr-x | bench.py | 63 |
1 files changed, 34 insertions, 29 deletions
@@ -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() |
