From: Hamed Gorjiara <hgorjiar@uci.edu> Date: Tue, 8 Sep 2020 02:40:59 +0000 (-0700) Subject: Scripts for analysing logs to compute learning time X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bd3a1e4b01ae72865fda6c8269029b345401c7be;p=satune.git Scripts for analysing logs to compute learning time --- diff --git a/src/Scripts/learningtimecomputer.py b/src/Scripts/learningtimecomputer.py new file mode 100644 index 0000000..285c816 --- /dev/null +++ b/src/Scripts/learningtimecomputer.py @@ -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() +