#!/usr/bin/env python2
-from optparse import OptionParser
-
-parser = OptionParser()
-parser.add_option("-i", "--infile", dest="infilename", help="read unparsed data from FILE", metavar="FILE", default="prefix.pre.dat")
-parser.add_option("-o", "--outfile", dest="outfilename", help="write parsed data to FILE.alg.dat", metavar="FILE", default="prefix")
-
-(options, args) = parser.parse_args()
-
-in_file = open(options.infilename, "r")
-
-algos = {
- 'datapar': [],
- 'hillis_sum': [],
- 'hillis_partial': [],
- 'seq': [],
- 'recurse': []
- }
-
-text = in_file.read()
-lines = text.split("\n")
-for line in lines:
- if line == "":
- continue
- elements = line.split(" ")
- for elem in elements:
- (key, value) = elem.split("=", 1)
- if key == 'binname':
- (_, prog) = value.split("/", 1)
- elif key == 'size':
- size = value
- elif key == 'time':
- time = value
- algos[prog].append({'size': size, 'time': time})
-
-in_file.close()
-
-for key in algos:
- out_file = open("stats/"+options.outfilename+"."+key+".dat", "w")
- for res in algos[key]:
- out_file.write(res['size']+";"+res['time']+"\n")
- out_file.close()
-
+import os
+
+statsdir = 'stats/raw/'
+
+runs = os.listdir(statsdir)
+#print runs
+
+bigrunlist = []
+for i in runs:
+ runfiles = os.listdir(statsdir+i)
+# print runfiles
+ for file in runfiles:
+# print "File: %s%s/%s" % (statsdir, i, file)
+ splitfilename = file.replace('hillis_', 'hillis-').split('_')
+ splitfilename[1] = splitfilename[1].replace('hillis-', 'hillis_')
+ dict = {}
+ dict['sched'] = splitfilename[0]
+ dict['algo'] = splitfilename[1]
+ dict['n'] = int(splitfilename[2].lstrip('n'))
+ fd = open(statsdir+i+'/'+file, "r")
+ fd_text = fd.read()
+ fd.close()
+ fd_lines = fd_text.split("\n")
+ for line in fd_lines:
+ if line == "":
+ continue
+ elements = line.split(" ")
+ for elem in elements:
+ (key, value) = elem.split("=", 1)
+ if key == 'binname':
+ (_, prog) = value.split("/", 1)
+ if prog != dict['algo']:
+ print "Failed: %s is not %s" % (prog, dict['algo'])
+ elif key == 'size':
+ size = int(value)
+ if size != dict['n']:
+ print "Failed: %s is not %s" % (size, dict['nvalue'])
+ elif key == 'time':
+ time = float(value)
+ dict['time'] = time
+ bigrunlist.append(dict)
+for i in bigrunlist:
+ print i