-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawStatistics.py
97 lines (83 loc) · 2.84 KB
/
drawStatistics.py
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
94
95
96
import numpy as np
import matplotlib.pyplot as plt
import pickle
def normalRead(fileName):
"""
Only read noOfPlanets and averageFPS
"""
data = []
try:
with open(fileName, "rb") as file:
data = pickle.load(file)
except (FileNotFoundError, EOFError) as e:
print(e)
exit()
noOfPlanets = []
averageFPS = []
for i in range(len(data)):
noOfPlanets.append(data[i][0])
averageFPS.append(data[i][3])
return noOfPlanets, averageFPS
if __name__ == "__main__":
cpuNoOfPlanets, cpuAverageFPS = normalRead("cpuData.pkl")
gpuNoOfPlanets, gpuAverageFPS = normalRead("gpuData.pkl")
data = []
try:
with open("statistics.pkl", "rb") as file:
data = pickle.load(file)
# Tuples as sorted by first element by default.
data.sort()
except (EOFError, FileNotFoundError) as e:
print(e)
exit()
noOfPlanets = []
averageFPS = []
allEffect = []
noEffect = []
onlySphere = []
onlyTail = []
# [(noOfPlanets, usePoint, withTail, FPS)]
for i in range(len(data)):
noOfPlanets.append(data[i][0])
averageFPS.append(data[i][3])
if data[i][1] and not data[i][2]:
noEffect.append(i)
elif data[i][1] and data[i][2]:
onlyTail.append(i)
elif not data[i][1] and data[i][2]:
allEffect.append(i)
elif not data[i][1] and not data[i][2]:
onlySphere.append(i)
noOfPlanets = np.array(noOfPlanets)
onlyTail = np.array(onlyTail)
onlySphere = np.array(onlySphere)
averageFPS = np.array(averageFPS)
# Draw
plt.plot(cpuNoOfPlanets, cpuAverageFPS, "r--", label="Only CPU")
plt.plot(gpuNoOfPlanets, gpuAverageFPS, "g--", label="Only GPU")
plt.title("Influence of Number of Planets (Only CPU and Only GPU)")
plt.xlabel("noOfPlanets")
plt.ylabel("average FPS")
plt.legend()
plt.show()
plt.plot(noOfPlanets[noEffect], averageFPS[noEffect], "r--", label="No Effect")
plt.plot(noOfPlanets[onlySphere], averageFPS[onlySphere], "g--", label="Only Sphere")
plt.title("Influence of Using Solid Sphere")
plt.xlabel("noOfPlanets")
plt.ylabel("average FPS")
plt.legend()
plt.show()
plt.plot(noOfPlanets[noEffect], averageFPS[noEffect], "r--", label="No Effect")
plt.plot(noOfPlanets[noEffect], averageFPS[onlyTail], "g--", label="Only Tail")
plt.title("Influence of Show Tails")
plt.xlabel("noOfPlanets")
plt.ylabel("average FPS")
plt.legend()
plt.show()
plt.plot(noOfPlanets[noEffect], averageFPS[noEffect], "r--", label="No Effect")
plt.plot(noOfPlanets[allEffect], averageFPS[allEffect], "g--", label="All Effect")
plt.title("Influence of All Effect")
plt.xlabel("noOfPlanets")
plt.ylabel("average FPS")
plt.legend()
plt.show()