diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-05 19:28:26 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-05 19:28:26 +0100 |
| commit | 639cfeb56d8c2928d820e6a3fa4cd86a2f2acb53 (patch) | |
| tree | 49e93bced2c034c67deaaefd7631f495844540e7 | |
| parent | b32c14b548e1e0476a4ba5ad5da2c504f3cdd4d9 (diff) | |
| download | allocbench-639cfeb56d8c2928d820e6a3fa4cd86a2f2acb53.tar.gz allocbench-639cfeb56d8c2928d820e6a3fa4cd86a2f2acb53.zip | |
rework rebuild mechanism to use timestamps instead of pickle strings
| -rwxr-xr-x | bench.py | 7 | ||||
| -rw-r--r-- | src/allocator.py | 29 | ||||
| -rw-r--r-- | src/globalvars.py | 4 |
3 files changed, 23 insertions, 17 deletions
@@ -65,11 +65,12 @@ def main(): allocators_file = os.path.join("build", "allocators", "allocators.py") if args.allocators or os.path.isfile(allocators_file): - allocators_files = args.allocators or allocators_file + allocators_file = args.allocators or allocators_file + src.globalvars.allocators_file = allocators_file - with open(allocators_files, "r") as f: + with open(allocators_file, "r") as f: print_status("Sourcing allocators definition ...") - g= {} + g = {} exec(f.read(), g) src.allocators.allocators = g["allocators"] diff --git a/src/allocator.py b/src/allocator.py index da666a9..7887272 100644 --- a/src/allocator.py +++ b/src/allocator.py @@ -1,6 +1,6 @@ import copy +from datetime import datetime import os -import pickle import shutil import subprocess import sys @@ -21,7 +21,6 @@ srcdir = os.path.join(builddir, "src") if not os.path.isdir(srcdir): os.makedirs(srcdir) - class Allocator_Sources (object): def __init__(self, name, retrieve_cmds=[], prepare_cmds=[], reset_cmds=[]): self.name = name @@ -99,18 +98,22 @@ class Allocator (object): def build(self): build_needed = not os.path.isdir(self.dir) - builddef_file = os.path.join(self.dir, ".builddef") + buildtimestamp_file = os.path.join(self.dir, ".buildtime") if not build_needed: - print_info2("Old build found. Comparing builddefs") + print_info2("Old build found. Comparing build time with mtime") + + with open(buildtimestamp_file, "r") as f: + timestamp = datetime.fromisoformat(f.read()) + + # print(globals()) + modtime = os.stat(os.path.realpath(src.globalvars.allocators_file)).st_mtime + modtime = datetime.fromtimestamp(modtime) - old_def = "" - with open(builddef_file, "rb") as f: - old_def = pickle.dumps(pickle.load(f)) - build_needed = old_def != pickle.dumps(self) + build_needed = timestamp < modtime - print_debug("Old Def.:", old_def) - print_debug("New Def.:", pickle.dumps(self)) + print_debug("Time of last build:", timestamp.isoformat()) + print_debug("Last modification of allocators file:", modtime.isoformat()) print_info2("Build needed:", build_needed) if build_needed: @@ -136,9 +139,9 @@ class Allocator (object): shutil.rmtree(self.dir, ignore_errors=True) exit(2) - with open(builddef_file, "wb") as f: - print_info2("Save build definition to:", builddef_file) - pickle.dump(self, f) + with open(buildtimestamp_file, "w") as f: + print_info2("Save build time to:", buildtimestamp_file) + f.write(str(datetime.now().isoformat())) print_info2("Create allocator dictionary") for attr in ["LD_PRELOAD", "cmd_prefix"]: diff --git a/src/globalvars.py b/src/globalvars.py index 1949816..afc8bf6 100644 --- a/src/globalvars.py +++ b/src/globalvars.py @@ -1 +1,3 @@ -verbosity = 0
\ No newline at end of file +verbosity = 0 + +allocators_file = None |
