Scripts for analysing logs to compute learning time
authorHamed Gorjiara <hgorjiar@uci.edu>
Tue, 8 Sep 2020 02:40:59 +0000 (19:40 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Tue, 8 Sep 2020 02:40:59 +0000 (19:40 -0700)
src/Scripts/learningtimecomputer.py [new file with mode: 0644]

diff --git a/src/Scripts/learningtimecomputer.py b/src/Scripts/learningtimecomputer.py
new file mode 100644 (file)
index 0000000..285c816
--- /dev/null
@@ -0,0 +1,46 @@
+import os
+import sys
+import random
+import re
+
+
+path = ''
+
+def validateArgs():
+       global path;
+       if len(sys.argv) != 2:
+               print("Wrong argument! Usage: python learningtimecomputer.py ./bin-sudoku-set0-alg2");
+               sys.exit(-1);
+       else:
+               path = sys.argv[1] + "/";
+
+
+def computeLearningTime():
+       learntime = 0;
+       for i in range(10000000):
+               logname = path + "log" + str(i);
+               timeout = -1;
+               if(not os.path.exists(logname)):
+                       break;
+               with open(logname) as fp:
+                       line = fp.readline()
+                       timeout = int(line.split()[2])
+               
+               resultname = path + "result" + str(i)
+               if(not os.path.exists(resultname) ):
+                       learntime += timeout
+               else:
+                       with open(resultname) as fp:
+                               line = fp.readline()
+                               learntime += long(line)*1.0/1000000000;
+
+       print("learning time: " + str(learntime*1.0/60) + " min" )
+               
+
+def main():
+       validateArgs();
+       computeLearningTime()
+
+if __name__ == "__main__":
+    main()
+