aboutsummaryrefslogtreecommitdiff
path: root/bench_loop.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2018-07-17 00:15:25 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2018-07-17 00:15:25 +0200
commit2026047c197bcf291733f8a4b3e5361f31e5cb77 (patch)
tree81f04f857a4ead7480e5277be0119ca1be143956 /bench_loop.py
parent9ef16832c7898b4d0af18fc12f1d11e24c4c925c (diff)
downloadallocbench-2026047c197bcf291733f8a4b3e5361f31e5cb77.tar.gz
allocbench-2026047c197bcf291733f8a4b3e5361f31e5cb77.zip
use ps instead of memusage to get rss and vsz
Diffstat (limited to 'bench_loop.py')
-rw-r--r--bench_loop.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/bench_loop.py b/bench_loop.py
index dcffa7f..c55f3ad 100644
--- a/bench_loop.py
+++ b/bench_loop.py
@@ -10,7 +10,7 @@ from common_targets import common_targets
cmd = ("perf stat -x\; -e cpu-clock:k,cache-references,cache-misses,cycles,"
"instructions,branches,faults,migrations "
- "build/memusage build/bench_loop{} 1.2 {} 1000000 {} 10")
+ "build/bench_loop{} 1.2 {} 1000000 {} 10")
class Benchmark_Loop():
def __init__(self):
@@ -49,6 +49,7 @@ class Benchmark_Loop():
# run cmd for each target
for tname, t in self.targets.items():
+ result = {"VSZ": [], "RSS" : []}
env = {"LD_PRELOAD" : t[1]} if t[1] != "" else None
@@ -56,12 +57,26 @@ class Benchmark_Loop():
if verbose:
print("\n" + tname, t, "\n", " ".join(target_cmd), "\n")
- p = subprocess.run(target_cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
+ p = subprocess.Popen(target_cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
env=env, universal_newlines=True)
+
+ while p.poll() == None:
+ ps = subprocess.run(["ps", "-F", "--ppid", str(p.pid)], stdout=subprocess.PIPE)
+ lines = ps.stdout.splitlines()
+ if len(lines) == 1: # perf hasn't forked yet
+ continue
+ tokens = str(lines[1]).split()
+ result["VSZ"].append(tokens[4])
+ result["RSS"].append(tokens[5])
+
+ p.wait()
+
+ output = p.stderr.read()
+
if p.returncode != 0:
print("\n" + " ".join(target_cmd), "exited with", p.returncode, ".\n Aborting Benchmark.")
print(tname, t)
- print(p.stderr)
+ print(output)
print(p.stdout)
return False
@@ -69,20 +84,8 @@ class Benchmark_Loop():
print("\nPreloading of", t[1], "failed for", tname, ".\n Aborting Benchmark.")
return False
- output = p.stderr.split("# End memusage\n")
- if len(output) != 2:
- print()
- print(output)
- print(tname, t)
- print("Aborting output is not correct")
-
- result = {}
- # Strip all whitespace from memusage output
- result["memusage"] = [x.replace(" ", "").replace("\t", "")
- for x in output[0].splitlines()]
-
# Handle perf output
- csvreader = csv.reader(output[1].splitlines(), delimiter=';')
+ csvreader = csv.reader(output.splitlines(), delimiter=';')
for row in csvreader:
result[row[2].replace("\\", "")] = row[0].replace("\\", "")
key = (tname, *args)