# Parse the sfsres log file generated by SPECsfs to generate more detailed
# latency statistics than in the sfssum summary file.
-import re, sys
+import re, subprocess, sys
def extract_re(lines, regexp):
if isinstance(regexp, str):
m = regexp.match(l)
if m: return m
+OPERATIONS = ('read', 'write', 'create', 'setattr', 'lookup', 'getattr')
+
+def parse_date(datestr):
+ p = subprocess.Popen(['/bin/date', '-d', datestr, '+%s'],
+ stdout=subprocess.PIPE)
+ d = p.stdout.read()
+ p.wait()
+ return int(d.strip())
+
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")
+ timestamp = extract_re(lines, r"SFS Aggregate Results.*, (.*)")
+ if timestamp is not None:
+ try:
+ timestamp = parse_date(timestamp.group(1))
+ except:
+ timestamp = None
# Extract the stable of per-operation counts, response times, etc.
regexp = re.compile(r"^(\w+)" + r"\s*([\d.]+)%?" * 9)
for l in lines:
m = regexp.match(l)
if m:
- table[m.group(1)] = [float(m.group(i)) for i in range(2, 11)]
+ try:
+ table[m.group(1)] = [float(m.group(i)) for i in range(2, 11)]
+ except:
+ #sys.stderr.write("Error parsing line: " + l.strip() + "\n")
+ pass
+ outfp.write("# finish_timestamp: " + str(timestamp) + "\n")
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]))
+ for o in OPERATIONS:
+ val = '-'
+ try: val = table[o][5]
+ except: pass
+ outfp.write("\t%s" % (val,))
outfp.write("\n")
def parse_sfsres(fp):
+ sys.stdout.write("# target_ops actual_ops latency_avg")
+ for o in OPERATIONS:
+ sys.stdout.write(" " + o)
+ sys.stdout.write("\n")
timestamp = None
run_data = []
for line in fp: