aboutsummaryrefslogtreecommitdiff
path: root/benchmark.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-08-31 23:45:40 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-08-31 23:45:40 +0200
commit0ea389f7b4048821a72020fb6a15ef9cb41c2b14 (patch)
tree2bf8b252c65f9635e1f22f93a82e64d3ba588844 /benchmark.py
parent00ec0f6340257cd82e596725aa077d6bfd15eef4 (diff)
downloadallocbench-0ea389f7b4048821a72020fb6a15ef9cb41c2b14.tar.gz
allocbench-0ea389f7b4048821a72020fb6a15ef9cb41c2b14.zip
change benchmark.py for mysql and remove run from mysql.py
also simplify chattymalloc because memusage fails for mysqld and fix glibc-no-tc
Diffstat (limited to 'benchmark.py')
-rw-r--r--benchmark.py70
1 files changed, 48 insertions, 22 deletions
diff --git a/benchmark.py b/benchmark.py
index 92a670d..2d5fc94 100644
--- a/benchmark.py
+++ b/benchmark.py
@@ -42,6 +42,7 @@ class Benchmark (object):
self.requirements = []
def save(self, path=None, verbose=False):
+ print(self.results)
f = path if path else self.name + ".save"
if verbose:
print("Saving results to:", self.name + ".save")
@@ -115,15 +116,19 @@ class Benchmark (object):
def analyse(self, verbose=False):
for perm in self.iterate_args():
- file_name = ".".join(list(self.name, *p.items()))
-
- actual_cmd = analyse_cmd.format(file_name + ".png")
- if "binary_suffix" in cmd:
- p["binary_suffix"] = ""
- actual_cmd += cmd.format(**perm._asdict())
+ perm = perm._asdict()
+ file_name = self.name + "."
+ file_name += ".".join([str(x) for x in perm.values()])
+ file_name += ".memusage"
+
+ actual_cmd = self.analyse_cmd.format(file_name + ".png")
+ if "binary_suffix" in self.cmd:
+ perm["binary_suffix"] = ""
+ actual_cmd += self.cmd.format(**perm)
with open(file_name + ".hist", "w") as f:
res = subprocess.run(actual_cmd.split(),
+ stdout=subprocess.PIPE,
stderr=f,
universal_newlines=True)
@@ -133,18 +138,34 @@ class Benchmark (object):
print("You may look at", file_name + ".hist", "to fix this.")
return
+ def parse_chattymalloc_data(self, path="chattymalloc.data"):
+ hist = {}
+ with open(path, "r") as f:
+ for l in f.readlines():
+ n = int(l)
+ hist[n] = hist.get(n, 0) + 1
+ return hist
def run(self, verbose=False, runs=5):
- n = len(list(self.iterate_args()))
+ n = len(list(self.iterate_args())) * len(self.targets)
+ i = 0
for run in range(1, runs + 1):
print(str(run) + ". run")
- for i, perm in enumerate(self.iterate_args()):
- print(i + 1, "of", n, "\r", end='')
+ for tname, t in self.targets.items():
+ if not tname in self.results:
+ self.results[tname] = {}
+
+ os.environ["LD_PRELOAD"] = "build/print_status_on_exit.so "
+ os.environ["LD_PRELOAD"] += t["LD_PRELOAD"]
+
+ if hasattr(self, "pretarget_hook"):
+ if self.pretarget_hook((tname, t), run, verbose):
+ return False
- for tname, t in self.targets.items():
- if not tname in self.results:
- self.results[tname] = {}
+ for perm in self.iterate_args():
+ i += 1
+ print(i + 1, "of", n, "\r", end='')
actual_cmd = self.perf_cmd
@@ -152,16 +173,13 @@ class Benchmark (object):
perm_dict.update(t)
actual_cmd += self.cmd.format(**perm_dict)
- os.environ["LD_PRELOAD"] = "build/print_status_on_exit.so "
- os.environ["LD_PRELOAD"] += t["LD_PRELOAD"]
-
res = subprocess.run(actual_cmd.split(),
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
universal_newlines=True)
if res.returncode != 0:
- print("\n" + actual_cmd, "exited with", res.returncode)
+ print("\n" + actual_cmd, "exited with", res.returncode, "for", tname)
print("Aborting Benchmark.")
print("Stdout:\n" + res.stdout)
print("Stderr:\n" + res.stderr)
@@ -175,7 +193,7 @@ class Benchmark (object):
result = {}
- # Read VmHWM from status file # If our benchmark didn't fork
+ # 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():
@@ -184,15 +202,23 @@ class Benchmark (object):
break
os.remove("status")
- # Parse perf output
- csvreader = csv.reader(res.stderr.splitlines(), delimiter=',')
- for row in csvreader:
- # Split of the user/kernel space info to be better portable
- result[row[2].split(":")[0]] = row[0]
+ if hasattr(self, "process_stdout"):
+ self.process_stdout(result, res.stdout)
+
+ # Parse perf output if available
+ if self.perf_cmd != "":
+ csvreader = csv.reader(res.stderr.splitlines(), delimiter=',')
+ for row in csvreader:
+ # Split of the user/kernel space info to be better portable
+ result[row[2].split(":")[0]] = row[0]
if run == 1:
self.results[tname][perm] = []
self.results[tname][perm].append(result)
+
+ if hasattr(self, "posttarget_hook"):
+ if self.posttarget_hook((tname, t), run, verbose):
+ return False
print()
return True