Commit a538c67c authored by Ludwig Fueracker's avatar Ludwig Fueracker
Browse files

moved plotting to own functions

parent 0cb1f008
......@@ -187,6 +187,7 @@ def getSortedCommitIDList(fullRecord):
################################################################################
def plotBuildTimeGraph(measuredBuildTimes, realClangHashBuildTimes, optimalClangHashBuildTimes, optimalBuildTimes): # times in ms
fig, ax = plt.subplots()
......@@ -220,6 +221,42 @@ def plotBuildTimeCompositionGraph(parseTimes, hashTimes, compileTimes, diffToBui
fig.savefig(pathToRecords + '/../buildTimeComposition.png', bbox_extra_artists=(lgd,), bbox_inches='tight')
def plotTimeHistogram(times, filename):
#TODO: understand params and vars
hist, bins = np.histogram(times, bins=50)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
fig, ax = plt.subplots()
plt.xlabel('time [ms]')
plt.ylabel('#files')
ax.bar(center, hist, align='center', width=width)
fig.savefig(pathToRecords + filename)#, bbox_extra_artists=(lgd,), bbox_inches='tight')
def plotTimeHistograms(parseTimes, hashTimes, compileTimes): # times in ms
plotTimeHistogram(parseTimes, '/../parseTimeHistogram.png')
plotTimeHistogram(hashTimes, '/../hashTimeHistogram.png')
plotTimeHistogram(compileTimes, '/../compileTimeHistogram.png')
def plotChangesGraph(fileCounts, sameHashes, differentAstHashes, differentObjHashes):
fig, ax = plt.subplots()
ax.plot(fileCounts, label='#objfiles')
ax.plot(sameHashes, label='unchanged')
ax.plot(differentAstHashes, label='astHash differs')
ax.plot(differentObjHashes, label='objHash differs')
box = ax.get_position()
lgd = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) # legend on the right
plt.xlabel('commits')
plt.ylabel('#files')
fig.savefig(pathToRecords + '/../changes.png', bbox_extra_artists=(lgd,), bbox_inches='tight')
################################################################################
def makeBuildTimeGraph(fullRecord):
sortedCommitIDs = getSortedCommitIDList(fullRecord)
......@@ -301,19 +338,18 @@ def makeBuildTimeGraph(fullRecord):
################################################################################
def makeTimeHistograms(fullRecord):
#TODO: for parsing, hashing, compiling
'''plot histograms for parsing, hashing, compiling'''
sortedCommitIDs = getSortedCommitIDList(fullRecord)
iterCommits = iter(sortedCommitIDs)
prevCommit = fullRecord[next(iterCommits)]
#TODO: den ersten commit auch behandeln!!!
parseTimes = []
hashTimes = []
compileTimes = []
currentFiles = prevCommit[tr('files')]
for filename in currentFiles:
for filename in currentFiles: # deal with first commit
if tr('ast-hash') not in currentFiles[filename].keys():
print "error: missing AST hash for file %s" % filename
continue
......@@ -325,7 +361,6 @@ def makeTimeHistograms(fullRecord):
compileTimes.append(compileTime)
for commitID in iterCommits:
currentCommit = fullRecord[commitID]
currentFiles = currentCommit[tr('files')]
......@@ -349,44 +384,12 @@ def makeTimeHistograms(fullRecord):
compileTime = currentFiles[filename][tr('compile-duration')] / 1e6
compileTimes.append(compileTime)
#TODO: understand params and vars
hist, bins = np.histogram(parseTimes, bins=50)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
fig, ax = plt.subplots()
plt.xlabel('time [ms]')
plt.ylabel('#files')
ax.bar(center, hist, align='center', width=width)
fig.savefig(pathToRecords + '/../parseTimeHistogram.png')#, bbox_extra_artists=(lgd,), bbox_inche s='tight')
hist, bins = np.histogram(hashTimes, bins=50)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
fig, ax = plt.subplots()
plt.xlabel('time [ms]')
plt.ylabel('#files')
ax.bar(center, hist, align='center', width=width)
fig.savefig(pathToRecords + '/../hashTimeHistogram.png')#, bbox_extra_artists=(lgd,), bbox_inche s='tight')
hist, bins = np.histogram(compileTimes, bins=50)
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
fig, ax = plt.subplots()
plt.xlabel('time [ms]')
plt.ylabel('#files')
ax.bar(center, hist, align='center', width=width)
fig.savefig(pathToRecords + '/../compileTimeHistogram.png')#, bbox_extra_artists=(lgd,), bbox_inche s='tight')
plotTimeHistograms(parseTimes, hashTimes, compileTimes)
################################################################################
def makeChangesGraph(fullRecord):
sortedCommitIDs = getSortedCommitIDList(fullRecord)
iterCommits = iter(sortedCommitIDs)
......@@ -444,19 +447,8 @@ def makeChangesGraph(fullRecord):
# f_changes.write("%s;%s;%s;%s\n" % (commitID, differentAstHash, differentObjHash, same))
prevCommit = currentCommit
fig, ax = plt.subplots()
ax.plot(fileCounts, label='#objfiles')
ax.plot(sameHashes, label='unchanged')
ax.plot(differentAstHashes, label='astHash differs')
ax.plot(differentObjHashes, label='objHash differs')
box = ax.get_position()
lgd = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) # legend on the right
plotChangesGraph(fileCounts, sameHashes, differentAstHashes, differentObjHashes)
plt.xlabel('commits')
plt.ylabel('#files')
fig.savefig(pathToRecords + '/../changes.png', bbox_extra_artists=(lgd,), bbox_inches='tight')
################################################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment