-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStats.py
32 lines (31 loc) · 1.79 KB
/
Stats.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
def Stats(sys_cont_switches, sys_avg_CPU_burst_time, sys_avg_wait_times, sys_CPU_util,sys_num_preemps,sys_avg_turnaround_times):
#! statistics related to the 4 scheduling systems
#sched system names
sys_names = ["FCFS","SJF","SRT","RR"]
#sched system CPU util
#sched system preemption amounts
sys_preempts = [0,0] + sys_num_preemps
with open('simout.txt', 'w') as f:
for i in range(4):
f.writelines(["Algorithm ",sys_names[i],"\n"])
f.writelines(["-- average CPU burst time: ",str(sys_avg_CPU_burst_time)," ms\n"])
f.writelines(["-- average wait time: ",str(format(sys_avg_wait_times[i], ".3f"))," ms\n"])
f.writelines(["-- average turnaround time: ",str(sys_avg_turnaround_times[i])," ms\n"])
f.writelines(["-- total number of context switches: ",str(sys_cont_switches[i]),"\n"])
f.writelines(["-- total number of preemptions: ",str(sys_preempts[i]),"\n"])
f.writelines(["-- CPU utilization: ",str(sys_CPU_util[i]),"%\n"])
def stats():
#! statistics related to the 4 scheduling systems
#sched system names
sys_names = ["FCFS","SJF","SRT","RR"]
#sched system CPU util
#sched system preemption amounts
with open('simout.txt', 'w') as f:
for i in range(4):
f.writelines(["Algorithm ",sys_names[i],"\n"])
f.writelines(["-- average CPU burst time: ","0.000"," ms\n"])
f.writelines(["-- average wait time: ","0.000"," ms\n"])
f.writelines(["-- average turnaround time: ","0.000"," ms\n"])
f.writelines(["-- total number of context switches: ","0","\n"])
f.writelines(["-- total number of preemptions: ","0","\n"])
f.writelines(["-- CPU utilization: ","0.000","%\n"])