Resolving conflicts
[satune.git] / src / analyzer / tunerloganalyzer.py
index 2417621..d47df1f 100644 (file)
@@ -2,7 +2,7 @@ import re
 import argparse
 import sys
 import os
 import argparse
 import sys
 import os
-
+import plot as pl
 
 class AutoTunerArgParser:
        def __init__(self):
 
 class AutoTunerArgParser:
        def __init__(self):
@@ -62,10 +62,13 @@ def printHeader(file):
 def dump(file, row):
        global TUNABLEHEADER
        mystr=""
 def dump(file, row):
        global TUNABLEHEADER
        mystr=""
+       data = []
        for i in range(len(TUNABLEHEADER)):
                mystr += row[TUNABLEHEADER[i]]+ ","
        for i in range(len(TUNABLEHEADER)):
                mystr += row[TUNABLEHEADER[i]]+ ","
-       print "mystr is:"+ mystr
+               data.append(row[TUNABLEHEADER[i]])
+       print ("mystr is:"+ mystr)
        print >>file, mystr
        print >>file, mystr
+       return data
 
 def loadTunerInfo(row, filename):
        with open(filename) as f:
 
 def loadTunerInfo(row, filename):
        with open(filename) as f:
@@ -109,6 +112,7 @@ def analyzeLogs(file):
        argprocess = AutoTunerArgParser()
        printHeader(file)
        rows = []
        argprocess = AutoTunerArgParser()
        printHeader(file)
        rows = []
+       data = []
        for i in range(argprocess.getRunNumber()):
                row = {"DECOMPOSEORDER" : "",
                        "MUSTREACHGLOBAL" : "",
        for i in range(argprocess.getRunNumber()):
                row = {"DECOMPOSEORDER" : "",
                        "MUSTREACHGLOBAL" : "",
@@ -136,9 +140,9 @@ def analyzeLogs(file):
                loadTunerInfo(row, argprocess.getFolder()+"/tuner"+str(i)+"used")
                loadSolverTime(row, argprocess.getFolder()+"/log"+str(i))
                loadProblemName(row, argprocess.getFolder()+"/problem"+str(i))
                loadTunerInfo(row, argprocess.getFolder()+"/tuner"+str(i)+"used")
                loadSolverTime(row, argprocess.getFolder()+"/log"+str(i))
                loadProblemName(row, argprocess.getFolder()+"/problem"+str(i))
-               dump(file, row)
+               data.append(dump(file, row))
                rows.append(row)
                rows.append(row)
-       return rows
+       return rows, data
 
 def tunerCountAnalysis(file, rows):
        global TUNABLEHEADER
 
 def tunerCountAnalysis(file, rows):
        global TUNABLEHEADER
@@ -160,7 +164,7 @@ def tunerCountAnalysis(file, rows):
                        tunernumber[mystr] += "-" + str(row["TUNERNUMBER"])
 
        problems = set(map(lambda x: x["PROBLEM"], rows))
                        tunernumber[mystr] += "-" + str(row["TUNERNUMBER"])
 
        problems = set(map(lambda x: x["PROBLEM"], rows))
-       print "Number of repititive tuners"
+       print ("Number of repititive tuners")
        for key in tunercount:
                if tunercount[key] > 1:
                        print key + "(ids:" + tunernumber[key]  + ") = #" + str(tunercount[key])
        for key in tunercount:
                if tunercount[key] > 1:
                        print key + "(ids:" + tunernumber[key]  + ") = #" + str(tunercount[key])
@@ -179,12 +183,19 @@ def combineRowForEachTuner(rows):
                        newRows.append(combined)
        return newRows
 
                        newRows.append(combined)
        return newRows
 
+def transformDataset(rows):
+       print(rows)
+
+
 def main():
 def main():
+       global TUNABLEHEADER
        file = open("tuner.csv", "w")
        file = open("tuner.csv", "w")
-       rows = analyzeLogs(file)
+       rows, data = analyzeLogs(file)
        tunerCountAnalysis(file, combineRowForEachTuner(rows) )
        file.close()
        tunerCountAnalysis(file, combineRowForEachTuner(rows) )
        file.close()
-       return
+       #transformDataset(data)
+       pl.plot(data, TUNABLEHEADER)
+
 
 if __name__ == "__main__":
        main()
 
 if __name__ == "__main__":
        main()