--- /dev/null
+#!/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)