Commit script to parse microbenchmark results.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Mon, 14 Feb 2011 23:06:03 +0000 (15:06 -0800)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Mon, 14 Feb 2011 23:06:03 +0000 (15:06 -0800)
microbench/parse-results.py [new file with mode: 0755]

diff --git a/microbench/parse-results.py b/microbench/parse-results.py
new file mode 100755 (executable)
index 0000000..64a17d3
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/python2
+
+import os, re
+
+def load_results(prefix):
+    settings_file = open(prefix + ".settings")
+    results_file = open(prefix + ".results")
+
+    settings = {}
+    for l in settings_file:
+        l = l.strip()
+        try:
+            (k, v) = l.split('=', 1)
+            settings[k] = v
+        except: pass
+
+    results = []
+    result_group = {}
+    for l in results_file:
+        l = l.strip()
+        if len(l) == 0 and len(result_group) > 0:
+            results.append(result_group)
+            result_group = {}
+        m = re.match(r"^(\w+): \[(.*)\]$", l)
+        if m:
+            vals = [float(x.strip()) for x in m.group(2).split(',')]
+            result_group[m.group(1)] = vals
+    if len(result_group) > 0:
+        results.append(result_group)
+
+    return (settings, results)
+
+def extract(data, params={}, ty='read', index=0):
+    results = {}
+    for (s, r) in data:
+        match = True
+        for (k, v) in params.items():
+            if s[k] != v: match = False
+        if not match: continue
+
+        ops = int(s['BENCH_OPS'])
+
+        vals = [x[ty][index] for x in r]
+        vals = vals[5:]
+
+        results[ops] = sum(vals) / len(vals)
+    return results
+
+data = []
+if __name__ == '__main__':
+    for f in os.listdir('results'):
+        if f.endswith('.settings'):
+            data.append(load_results('results/' + f[:-len('.settings')]))
+
+for size in [128, 512, 1024, 2048]:
+    params = {'BLUESKY_TARGET': 'native', 'BENCH_WRITERATIO': '1.0',
+              'BENCH_FILECOUNT': str(size / 4)}
+
+    d0 = extract(data, params, ty='write', index=0)
+    d1 = extract(data, params, ty='write', index=1)
+
+    fp = open('%s-%d-write.data' % (params['BLUESKY_TARGET'], size), 'w')
+    for k in sorted(d0.keys()):
+        fp.write("%d\t%f\t%f\n" % (k, d0[k], d1[k]))
+    fp.close()