diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-20 16:14:32 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-20 16:14:32 +0200 |
| commit | 468865c5de6ce2365a4afb86aacc05d81c0329c4 (patch) | |
| tree | 3bc16da70c356aeab21e7ddd5d431e0ec8219e54 /src/benchmark.py | |
| parent | b7ab05c6d3e960a0b794e8c39cf41d045f9bf6ca (diff) | |
| download | allocbench-lld.tar.gz allocbench-lld.zip | |
add lld benchmark using lld provided benchmarkslld
Benchmark changes the current working directory if self.run_dir is
set befor each benchmark run.
lld does not work with print_status_on_exit.so so reading and removing
status is no only done if a status file is available.
Diffstat (limited to 'src/benchmark.py')
| -rw-r--r-- | src/benchmark.py | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/benchmark.py b/src/benchmark.py index 25a2fa8..28b2b5c 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -173,7 +173,7 @@ class Benchmark (object): self.calc_desc_statistics() def prepare(self): - os.environ["PATH"] += os.pathsep + "build/benchmarks/" + self.name + os.environ["PATH"] += f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}" for r in self.requirements: exe = src.util.find_cmd(r) @@ -243,6 +243,8 @@ class Benchmark (object): ret = server.poll() if ret is not None: + print_debug("Stdout:", server.stdout) + print_debug("Stderr:", server.stderr) raise Exception("Starting Server failed with exit code " + str(ret)) # Register termination of the server atexit.register(Benchmark.terminate_subprocess, popen=server) @@ -290,7 +292,7 @@ class Benchmark (object): env = dict(os.environ) env["LD_PRELOAD"] = env.get("LD_PRELOAD", "") - env["LD_PRELOAD"] += " " + "build/print_status_on_exit.so" + env["LD_PRELOAD"] += " " + f"{src.globalvars.builddir}/print_status_on_exit.so" env["LD_PRELOAD"] += " " + alloc["LD_PRELOAD"] if "LD_LIBRARY_PATH" in alloc: @@ -326,7 +328,7 @@ class Benchmark (object): measure_argv = src.util.prefix_cmd_with_abspath(measure_argv).split() argv.extend(measure_argv) - argv.extend(["build/exec", "-p", env["LD_PRELOAD"]]) + argv.extend([f"{src.globalvars.builddir}/exec", "-p", env["LD_PRELOAD"]]) if alloc["LD_LIBRARY_PATH"] != "": argv.extend(["-l", env["LD_LIBRARY_PATH"]]) @@ -334,6 +336,12 @@ class Benchmark (object): argv.extend(cmd_argv) + cwd = os.getcwd() + if hasattr(self, "run_dir"): + run_dir = self.run_dir.format(**substitutions) + os.chdir(run_dir) + print_debug("\nChange cwd to:", run_dir) + print_debug("\nCmd:", argv) res = subprocess.run(argv, stderr=subprocess.PIPE, stdout=subprocess.PIPE, @@ -353,15 +361,16 @@ class Benchmark (object): # parse and store results else: if self.server_cmds == []: - # Read VmHWM from status file. If our benchmark - # didn't fork the first occurance of VmHWM is from - # our benchmark - with open("status", "r") as f: - for l in f.readlines(): - if l.startswith("VmHWM:"): - result["VmHWM"] = l.split()[1] - break - os.remove("status") + if os.path.isfile("status"): + # Read VmHWM from status file. If our benchmark + # didn't fork the first occurance of VmHWM is from + # our benchmark + with open("status", "r") as f: + for l in f.readlines(): + if l.startswith("VmHWM:"): + result["VmHWM"] = l.split()[1] + break + os.remove("status") # TODO: get VmHWM from servers else: result["server_status"] = [] @@ -394,6 +403,9 @@ class Benchmark (object): self.results[alloc_name][perm] = [] self.results[alloc_name][perm].append(result) + if os.getcwd() != cwd: + os.chdir(cwd) + self.shutdown_servers() if hasattr(self, "postallocator_hook"): @@ -403,7 +415,8 @@ class Benchmark (object): print() # reset PATH - os.environ["PATH"] = os.environ["PATH"].replace(":build/" + self.name, "") + os.environ["PATH"] = os.environ["PATH"].replace(f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}", "") + # expand invalid results if valid_result != {}: |
