--- /dev/null
+import re
+import argparse
+import sys
+
+
+class AutoTunerArgParser:
+ def __init__(self):
+ self.parser = argparse.ArgumentParser(description='Parsing the output log of the CSolver auto tuner ...')
+ self.parser.add_argument('--file', '-f', metavar='out.log', type=str, nargs=1,help='output log of running the autotuner ...')
+ self.args = self.parser.parse_args()
+
+ def getFileName(self):
+ return self.args.file[0]
+
+configs = {"SMTTIME": "-",
+ "EXPLORETIME":"-",
+ "TESTCASE":"-",
+ }
+
+REGEXES = {"SMTTIME": "(.*)Actual SMT Solving Time: (.*)",
+ "EXPLORETIME":"(.*)EXPLORATION TIME: (.*)",
+ "TESTCASE": "(.*)Running tests from: (.+)",
+ }
+
+def printHeader(file):
+ global configs
+ mystr=""
+ for config in configs:
+ mystr+=str(config)+","
+ print >>file, mystr
+
+def printConfig(file, data):
+ print data
+ mystr=""
+ for config in data:
+ mystr+=str(data[config])+","
+ print >> file, mystr
+
+def main():
+ global configs
+ argprocess = AutoTunerArgParser()
+ output = open("tuner.csv", "w")
+ printHeader(output)
+ with open(argprocess.getFileName()) as file:
+ for line in file:
+ if line.startswith("Mutating"):
+ printConfig(output,configs)
+ elif line.startswith("Best tuner"):
+ printConfig(output,configs);
+ else :
+ for regex in REGEXES:
+ p = re.compile(REGEXES[regex])
+ token = p.search(line)
+ if token is not None:
+ if regex == "TESTCASE" or regex == "EXPLORETIME":
+ print line
+ configs[regex] = re.search(REGEXES[regex], line).group(1)
+ else:
+ configs[regex] = re.findall("\d+\.?\d*", line)[0]
+ if float(configs[regex]) > 1.0 :
+ print "SMTTime: " + configs[regex]
+
+
+ configs["EXECTIME"] = "BEST TUNE:"
+ printConfig(output, configs)
+ print "Done with parsing " + argprocess.getFileName()
+
+if __name__ == "__main__":
+ main()