-
Notifications
You must be signed in to change notification settings - Fork 8
/
plotter.py
61 lines (43 loc) · 1.35 KB
/
plotter.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
import numpy as np
import matplotlib.pyplot as plt
def preprocess(contents):
data = contents[0].split(", ")
for d in range(len(data)):
if "[" in data[d]:
data[d] = data[d].replace("[", "")
if "]" in data[d]:
data[d] = data[d].replace("]", "")
data[d] = int(data[d])
return data
def timer(data):
starter = 0
end = 0
flag_start = False
for d in range(len(data)):
if data[d] > 0 and flag_start == False:
print(data[d], d)
starter = d
flag_start = True
if sum(data[d:]) == 0:
end = d
break
return starter, end
with open("workload.txt") as f:
contents_workload = f.readlines()
data_workload = preprocess(contents_workload)
with open("workload_delete.txt") as f:
contents_delete = f.readlines()
data_delete = preprocess(contents_delete)
with open("workload_create.txt") as f:
contents_create = f.readlines()
data_create = preprocess(contents_create)
sw, ew = timer(data_workload)
sd, ed = timer(data_delete)
sc, ec = timer(data_create)
s, e = min(sw, sd, sc) - 10, max(ew, ed, ec) + 10
x = np.arange(s, e)
plt.plot(x, data_workload[s:e], label="workload")
plt.plot(x, data_delete[s:e], label="delete")
plt.plot(x, data_create[s:e], label="create")
plt.legend(loc="upper right")
plt.savefig("plts.png")