diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2018-07-17 00:15:25 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2018-07-17 00:15:25 +0200 |
| commit | 2026047c197bcf291733f8a4b3e5361f31e5cb77 (patch) | |
| tree | 81f04f857a4ead7480e5277be0119ca1be143956 /bench_conprod.py | |
| parent | 9ef16832c7898b4d0af18fc12f1d11e24c4c925c (diff) | |
| download | allocbench-2026047c197bcf291733f8a4b3e5361f31e5cb77.tar.gz allocbench-2026047c197bcf291733f8a4b3e5361f31e5cb77.zip | |
use ps instead of memusage to get rss and vsz
Diffstat (limited to 'bench_conprod.py')
| -rw-r--r-- | bench_conprod.py | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/bench_conprod.py b/bench_conprod.py index 44da48a..17c98eb 100644 --- a/bench_conprod.py +++ b/bench_conprod.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_conprod{0} {1} {1} {1} 1000000 {2}") + "build/bench_conprod{0} {1} {1} {1} 1000000 {2}") class Benchmark_ConProd(): def __init__(self): @@ -49,6 +49,7 @@ class Benchmark_ConProd(): # 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,33 +57,35 @@ class Benchmark_ConProd(): 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(p.stdout) + print(output) return False if "ERROR: ld.so" in p.stderr: 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) |
