]> git.somenet.org - pub/jan/parprog.git/blob - merge/parseDat.py
GITOLITE.txt
[pub/jan/parprog.git] / merge / parseDat.py
1 #!/usr/bin/env python2
2
3 import os, subprocess
4
5 def listtofile(listing, file):
6         fd = open(file, 'r')
7         for i in listing:
8                 fd.write(i+"\n")
9         fd.close()
10
11 def makeGraphs(graphs, graphtitle = "Title", xlabel = "Number of Parts", 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)
15         # now do the plots
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
26                 plots = []
27                 for title, file, cols in graphs[graphfile]:
28                         plots.append("'"+file+"' using "+cols+" title '"+title+"' with lines")
29                 plotcommand = ", ".join(plots)
30                 #print gendir+graphfile
31                 p.stdin.write("plot "+plotcommand+"\n")
32         p.communicate()[0]
33         p.stdin.close()
34
35 statsdir = 'stats/raw/'
36 runs = os.listdir(statsdir)
37 #print runs
38
39 gendir = "stats/generated/"
40 graphs = []
41 outpng = 'merge.png'
42 subprocess.call(["mkdir", "-p", gendir])
43 for i in runs:
44         runfiles = os.listdir(statsdir+i)
45 #       print runfiles
46         for file in runfiles:
47 #               print "File: %s%s/%s" % (statsdir, i, file)
48                 splitfilename = file.split('.')
49                 dict = {}
50                 dict['arrsize'] = splitfilename[1]
51                 graphs.append((splitfilename[1], statsdir+i+'/'+file, '1:2'))
52
53 makeGraphs({outpng: graphs}, "merge")