5 def listtofile(listing, file):
11 def makeGraphs(graphs, graphtitle = "Title", xlabel = "Numbers calculated", ylabel = "Time needed for calculation"):
12 gendir = "stats/generated/"
13 subprocess.call(["mkdir", "-p", gendir])
14 p = subprocess.Popen(['gnuplot'],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
16 for graphfile in graphs:
17 # set output 'filename'
18 p.stdin.write("set terminal png font arial 8 #size 600,300\n")
19 p.stdin.write("set grid\n")
20 p.stdin.write("set datafile separator ';'\n")
21 p.stdin.write("set title 'Timing of each "+graphtitle+"'\n")
22 p.stdin.write("set xlabel '"+xlabel+"'\n")
23 p.stdin.write("set ylabel '"+ylabel+"'\n")
24 p.stdin.write("set output '"+gendir+graphfile+"'\n")
25 # plot 'filename' using 1:2 title 'algorithm' with lines, 'filename2' using 1:2 title 'algo2' with lines
27 for title, file, cols in graphs[graphfile]:
28 plots.append("'"+gendir+file+"' using "+str(cols)+" title '"+str(title)+"' with lines")
29 plotcommand = ", ".join(plots)
30 #print gendir+graphfile
31 p.stdin.write("plot "+plotcommand+"\n")
35 statsdir = 'stats/raw/'
36 runs = os.listdir(statsdir)
41 runfiles = os.listdir(statsdir+i)
44 # print "File: %s%s/%s" % (statsdir, i, file)
45 splitfilename = file.split('_')
47 dict['no'] = int(splitfilename[0].lstrip('no'))
48 dict['nnp'] = int(splitfilename[1].lstrip('nnp'))
49 dict['n'] = int(splitfilename[2].lstrip('n'))
50 fd = open(statsdir+i+'/'+file, "r")
53 fd_lines = fd_text.split("\n")
57 elements = line.split(" ")
60 if elements[1] != "timings:":
63 (key, value) = elem.split(":", 1)
65 dict['prep'] = float(value)
67 dict['algo'] = float(value)
69 dict['postp'] = float(value)
71 dict['end'] = float(value)
72 bigrunlist.append(dict)
78 if not (i['no'], i['nnp'], i['n']) in foolist:
79 foolist[(i['no'], i['nnp'], i['n'])] = [i['end']]
81 foolist[(i['no'], i['nnp'], i['n'])].append(i['end'])
82 if not i['no'] in nos:
84 if not i['nnp'] in nnps:
88 #print "NOs: %s" % nos
89 #print "NNPs: %s" % nnps
93 minval = min(foolist[key])
94 uniquelist.append((key[0], key[1], key[2], minval))
99 if i[0] not in alg_dict:
101 if i[1] not in alg_dict[i[0]]:
102 alg_dict[i[0]][i[1]] = []
103 alg_dict[i[0]][i[1]].append(str(i[2])+";"+str(i[3]))
104 if i[1] not in sched_dict:
105 sched_dict[i[1]] = {}
106 if i[0] not in sched_dict[i[1]]:
107 sched_dict[i[1]][i[0]] = []
108 sched_dict[i[1]][i[0]].append(str(i[2])+";"+str(i[3]))
109 #print "od["+i[0]+"]["+i[1]+"] = "+str(i[2])+":"+str(i[3])
113 gendir = "stats/generated/"
114 subprocess.call(["mkdir", "-p", gendir])
116 pngfile = 'no.'+str(alg)+'.png'
117 graphs_alg[pngfile] = []
118 for sched in alg_dict[alg]:
119 datfile = 'data.no'+str(alg)+'.nnp'+str(sched)+'.dat'
120 fh = open(gendir+datfile, 'a+')
121 graphs_alg[pngfile].append((sched, datfile, '1:2'))
122 for dot in alg_dict[alg][sched]:
125 for sched in sched_dict:
126 pngfile = 'nnp.'+str(sched)+'.png'
127 graphs_sched[pngfile] = []
128 for alg in sched_dict[sched]:
129 datfile = 'data.no'+str(alg)+'.nnp'+str(sched)+'.dat'
130 graphs_sched[pngfile].append((alg, datfile, '1:2'))
132 #graphs['test1.png'] = [('linetitle1', 'prefix.hillis.dat', '1:2')]
134 makeGraphs(graphs_alg, "no")
135 makeGraphs(graphs_sched, "nnp")