Script for parsing sfsres files to extract more detailed latency values
authorMichael Vrable <mvrable@cs.ucsd.edu>
Sun, 6 Mar 2011 23:27:51 +0000 (15:27 -0800)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Sun, 6 Mar 2011 23:27:51 +0000 (15:27 -0800)
results/parse-sfsres.py [new file with mode: 0755]

diff --git a/results/parse-sfsres.py b/results/parse-sfsres.py
new file mode 100755 (executable)
index 0000000..96de28a
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+# coding=utf-8
+#
+# Parse the sfsres log file generated by SPECsfs to generate more detailed
+# latency statistics than in the sfssum summary file.
+
+import re, sys
+
+def extract_re(lines, regexp):
+    if isinstance(regexp, str):
+        regexp = re.compile(regexp)
+    for l in lines:
+        m = regexp.match(l)
+        if m: return m
+
+def parse_run(lines, timestamp, outfp=sys.stdout):
+    #print timestamp
+    requested_load = extract_re(lines, r"\s*Requested Load.*= (\d+)")
+    load = int(requested_load.group(1))
+    results = extract_re(lines, r"SFS NFS THROUGHPUT:\s*([\d.]+).*RESPONSE TIME:\s*([\d.]+) Msec/Op")
+
+    # Extract the stable of per-operation counts, response times, etc.
+    regexp = re.compile(r"^(\w+)" + r"\s*([\d.]+)%?" * 9)
+    table = {}
+    for l in lines:
+        m = regexp.match(l)
+        if m:
+            table[m.group(1)] = [float(m.group(i)) for i in range(2, 11)]
+
+    outfp.write("%d\t%s\t%s" % (load, results.group(1), results.group(2)))
+    for o in ('read', 'write', 'getattr'):
+        outfp.write("\t%s\t%s" % (table[o][5], table[o][6]))
+    outfp.write("\n")
+
+def parse_sfsres(fp):
+    timestamp = None
+    run_data = []
+    for line in fp:
+        m = re.match(r"^([^*]+) \*{32,}$", line)
+        if m:
+            if len(run_data) > 0:
+                parse_run(run_data, timestamp)
+            run_data = []
+            timestamp = m.group(1)
+        else:
+            run_data.append(line)
+    if len(run_data) > 0:
+        parse_run(run_data, timestamp)
+
+if __name__ == '__main__':
+    parse_sfsres(sys.stdin)