-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProportionOneGraphFiles.py
More file actions
96 lines (65 loc) · 2.13 KB
/
ProportionOneGraphFiles.py
File metadata and controls
96 lines (65 loc) · 2.13 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Given a .json file, creates a double line graph of the proportion of Test Files/Lines vs Source at each Commit
import json
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import os
fileTypes = ["java", "py", "js"] # List of all language types to check
graphName = "Proportion" # const
# Used for subfolder name
def makeGraph( fileType, i):
allFiles = os.listdir("./results/" + i)
fig, ax = plt.subplots()
for f in allFiles:
fileName = f
f = "./results/" + i + "/" + f
print(f)
fp = open(f, "r")
data = json.load(fp)
if(data["source_commits"] > 10000):
continue
fp.close()
xData = []
yData = []
yData2 = []
y = 0
y2 = 0
y3 = 0
y4 = 0
for a in range(len(data["number_of_test_files_per_commit"])):
xData.append(a+1)
y = y + data["number_of_test_files_per_commit"][a]
y2 = y2 + data["number_of_files_per_commit"][a]
if (y+y2) == 0: # y2 might be zero during division
yData.append(0)
else:
yData.append(float(y)/float(y+y2)*100)
y3 = y3 + data["test_lines_per_commit"][a]
y4 = y4 + data["total_lines_per_commit"][a]
if (y3+y4) == 0:
yData2.append(0)
else:
yData2.append(float(y3)/float(y3+y4)*100)
x = xData
y = yData # test files per commit
y2 = yData2 # test lines per commit
#ax.plot(x, y2, label="Lines")
ax.plot(x, y)
#ax.plot(x, y2, label="Lines")
ax.legend()
fileName = fileName.split(".json")[0]
ax.set(xlabel="Commit #", ylabel="Percentage(%)", title="Percentage of Test Material vs Total Material ")
ax.grid()
plt.ylim(0, 100)
try:
os.mkdir("./results/" + graphName + "/" + fileType)
except:
pass
plt.savefig('{}.png'.format("./results/" + graphName + "/" + fileType + "Files" ))
plt.close()
try:
os.mkdir("./results/" + graphName)
except:
pass
for i in fileTypes:
makeGraph(i,i)