-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFilesVsCommits.py
More file actions
67 lines (51 loc) · 1.57 KB
/
FilesVsCommits.py
File metadata and controls
67 lines (51 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Given a .json file, creates a double line graph of total lines of Code (Test and All) at each Commit
import json
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
fileTypes = ["java", "python", "javascript"] # List of all language types to check
graphName = "FilesVsCommits" # const
# Used for subfolder name
def makeGraph(f, data, fileType, fileName):
xData = []
yData = []
yData2 = []
y = 0
y2 = 0
for i in range(len(data["number_of_test_files_per_commit"])):
xData.append(i+1)
y = y + data["number_of_test_files_per_commit"][i]
y2 = y2 + data["number_of_files_per_commit"][i]
yData.append(y)
yData2.append(y2)
x = xData
y = yData
y2 = yData2
fig, ax = plt.subplots()
ax.plot(x, y, label="Test Files")
ax.plot(x, y2, label="All Files")
ax.legend()
fileName = fileName.split(".json")[0]
ax.set(xlabel="Commit #", ylabel="Total Files", title="Total Files At Each Commit (" + fileName + ")")
ax.grid()
try:
os.mkdir("./results/" + graphName + "/" + fileType)
except:
pass
plt.savefig('{}.png'.format("./results/" + graphName + "/" + fileType + "/" + fileName))
plt.close()
try:
os.mkdir("./results/" + graphName)
except:
pass
for i in fileTypes:
allFiles = os.listdir("./results/" + i)
for f in allFiles:
fileName = f
f = "./results/" + i + "/" + f
print(f)
fp = open(f, "r")
data = json.load(fp)
fp.close()
makeGraph(f, data, i, fileName)