-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.py
90 lines (69 loc) · 2.79 KB
/
logs.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
from member import member
import functools
import cfg
def init():
print("\n******************************************************")
def get_mean_system_time(mems):
print("Mean system time: ", end="\n")
ls = list(map(lambda x: x.get_system_time(), mems))
print("==>", sum(ls) / len(ls))
pass
def get_mean_system_time_per_priority(mems):
print("Mean system time per type: ", end="\n")
mm1ls = member.get_priority1_ls(mems)
ls = list(map(lambda x: x.get_system_time(), mm1ls))
print("==> type1", sum(ls) / len(ls))
mm2ls = member.get_priority2_ls(mems)
ls = list(map(lambda x: x.get_system_time(), mm2ls))
print("==> type2", sum(ls) / len(ls))
pass
def get_mean_waiting_time(mems):
print("Mean waiting time: ", end="\n")
ls = list(map(lambda x: x.get_queue_time(), mems))
print("==>", sum(ls) / len(ls))
pass
def get_mean_waiting_time_per_priority(mems):
print("Mean waiting time per type: ", end="\n")
mm1ls = member.get_priority1_ls(mems)
ls = list(map(lambda x: x.get_queue_time(), mm1ls))
print("==> type1", sum(ls) / len(ls))
mm2ls = member.get_priority2_ls(mems)
ls = list(map(lambda x: x.get_queue_time(), mm2ls))
print("==> type2", sum(ls) / len(ls))
pass
def get_percent_of_dead_tasks(mems):
print("Percent of dead tasks: ", end="\n")
podt = functools.reduce(
lambda a, b: a + 1 if b.isDead else a, mems, 0) / len(mems)
print("==>", podt*100)
pass
def get_percent_of_dead_tasks_per_priority(mems):
print("Percent of dead tasks per type: ", end="\n")
mm1ls = member.get_priority1_ls(mems)
podt = functools.reduce(
lambda a, b: a + 1 if b.isDead else a, mm1ls, 0) / len(mm1ls)
print("==> type1", podt*100)
mm2ls = member.get_priority2_ls(mems)
podt = functools.reduce(
lambda a, b: a + 1 if b.isDead else a, mm2ls, 0) / len(mm2ls)
print("==> type2", podt*100)
pass
def mean_queue_length_scheduler(mems):
print("Mean queue length scheduler: ", end="\n")
mean_len = functools.reduce(
lambda a, b: a + b.get_queue1_time(), mems, 0) / cfg.current_time
print("==>", mean_len)
pass
def mean_queue_length_server(mems):
print("Mean queue length server: ", end="\n")
mems1 = list(filter(lambda x: x.service_queue == 1, mems))
mems2 = list(filter(lambda x: x.service_queue == 2, mems))
mems3 = list(filter(lambda x: x.service_queue == 3, mems))
mems4 = list(filter(lambda x: x.service_queue == 4, mems))
mems5 = list(filter(lambda x: x.service_queue == 5, mems))
memsls = [mems1, mems2, mems3, mems4, mems5]
for i in range(1, len(memsls)+1):
mean_len = functools.reduce(
lambda a, b: a + b.get_queue2_time(), memsls[i-1], 0) / cfg.current_time
print(f"==> service{i}:", mean_len)
pass