aboutsummaryrefslogtreecommitdiff
path: root/bench.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2020-07-11 20:37:44 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2020-07-11 20:37:44 +0200
commit5a7c2c36f1ef0623d95268e05ca767653d82d676 (patch)
treec2713836dc6783d96e63b6794ab4993dfba03f3c /bench.py
parent7984c0c6c9570871f4a0976bece0721ee3150255 (diff)
downloadallocbench-5a7c2c36f1ef0623d95268e05ca767653d82d676.tar.gz
allocbench-5a7c2c36f1ef0623d95268e05ca767653d82d676.zip
replace directory string constants in globalvars with Path objects from allocbench.directory
Diffstat (limited to 'bench.py')
-rwxr-xr-xbench.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/bench.py b/bench.py
index 4458681..8d786d5 100755
--- a/bench.py
+++ b/bench.py
@@ -28,6 +28,7 @@ import traceback
from allocbench.allocator import collect_allocators
from allocbench.analyse import analyze_bench, analyze_allocators
from allocbench.benchmark import get_benchmark_object
+from allocbench.directories import get_current_result_dir, set_current_result_dir
import allocbench.facter as facter
import allocbench.globalvars
from allocbench.util import run_cmd
@@ -40,21 +41,24 @@ from summarize import summarize
def epilog():
"""Run tasks on exit"""
- # After early errors resdir may not be set
- if allocbench.globalvars.RESDIR is not None:
- if os.listdir(allocbench.globalvars.RESDIR) == []:
- print_warn("Remove empty resultdir")
- os.removedirs(allocbench.globalvars.RESDIR)
- else:
- endtime = datetime.datetime.now().isoformat()
- endtime = endtime[:endtime.rfind(':')]
- facter.FACTS["endtime"] = endtime
- facter.store_facts(allocbench.globalvars.RESDIR)
-
# remove a left over status file if some is present
if os.path.exists("status"):
os.remove("status")
+ res_dir = get_current_result_dir()
+ # After early errors resdir may not be set
+ if not res_dir:
+ return
+
+ if not res_dir.iterdir():
+ print_warn("Remove empty resultdir")
+ res_dir.rmdir()
+ else:
+ endtime = datetime.datetime.now().isoformat()
+ endtime = endtime[:endtime.rfind(':')]
+ facter.FACTS["endtime"] = endtime
+ facter.store_facts(res_dir)
+
def check_dependencies():
"""Check if known requirements of allocbench are met"""
@@ -149,14 +153,13 @@ def main():
# Create result directory
if args.resultdir:
- allocbench.globalvars.RESDIR = os.path.join(args.resultdir)
+ set_current_result_dir(args.resultdir)
else:
- allocbench.globalvars.RESDIR = os.path.join("results",
- facter.FACTS["hostname"],
- facter.FACTS["starttime"])
+ set_current_result_dir(
+ os.path.join("results", facter.FACTS["hostname"],
+ facter.FACTS["starttime"]))
- print_status("Writing results to:", allocbench.globalvars.RESDIR)
- os.makedirs(allocbench.globalvars.RESDIR, exist_ok=True)
+ print_status("Writing results to:", get_current_result_dir())
cwd = os.getcwd()
@@ -214,7 +217,7 @@ def main():
start_time).total_seconds()
# Save results in resultdir
- bench.save(allocbench.globalvars.RESDIR)
+ bench.save(get_current_result_dir())
if hasattr(bench, "cleanup"):
print_status("Cleaning up", bench.name, "...")