-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
68 lines (56 loc) · 1.54 KB
/
plot.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
import matplotlib.pyplot as plt
GRAPH_DATA_FILE = 'graphdata2'
def readValues(number, x, y):
with open (GRAPH_DATA_FILE) as f:
for line in f:
text = line[:-1].split()
if len(text) == 0 or text[0] != 'GRAPH':
continue;
if number == int(text[1]):
if len(x) > 0:
for i in range(x[-1] + 1, int(text[2])):
x.append(i)
y.append(y[-1])
x.append(int(text[2]))
y.append(int(text[3]))
def processQueueGraph():
plt.subplots_adjust(left=0.015, bottom=0.025, right=0.995, top=0.99, wspace=0.03, hspace=0.2)
colors = plt.cm.get_cmap('hsv', 10)
for i in range(0, 10):
x = []
y = []
readValues(i, x, y)
plt.subplot(5, 2, i + 1)
plt.scatter(x, y, label = 'P' + str(i), marker='.', s=5, c=colors(i))
plt.legend(markerscale=5, loc='upper left')
plt.yticks([0, 1, 2, 3, 4])
plt.show()
def totalTimeGraph(noOfCPU):
# Uses hard-coded values
data = [
{},
{
'RR': 2018,
'FCFS': 3586,
'PBS': 2005,
'MLFQ': 2045
},
{
'RR': 2006,
'FCFS': 2302,
'PBS': 2008,
'MLFQ': 2010
}
]
colors = ['#e00', '#770', '#077', '#00e']
algos = list(data[noOfCPU].keys())
times = list(data[noOfCPU].values())
barlist = plt.bar(algos, times, width=0.5)
for i in range(0, len(times)):
barlist[i].set_color(colors[i])
plt.axhline(y=times[i], c=colors[i])
plt.xlabel("Scheduling Algorithm")
plt.ylabel("Total ticks")
plt.title("Number of CPU = " + str(noOfCPU))
plt.show()
processQueueGraph()