Exemplo n.º 1
0
def print_metrics(cpu_state: CpuState):
    """
    CPU UTILIZATION - idle time/ run time
    Throughput - processes completed per time unity
    Waiting Time - time in ready queue
    Turnaround Time - time of arrival to time of running queue exit
    Response Time - time of submission to time or process started
    """

    print("\n================= METRICS =================\n")
    uti = cpu_state.idle_ticks / cpu_state.last_exit_tick
    uti = 1 - uti
    uti = round_three(uti)
    print(f"UTI: {uti}%")

    runtime_seconds = Units.MiS_to_seconds(cpu_state.last_exit_tick)
    tpt = CONFIG.total_jobs / runtime_seconds
    tpt = round_three(tpt)
    print(f"TPT: {tpt} Processes per Second")

    tot_wait_time = Units.MiS_to_seconds(cpu_state.wtt_rolling_time_sum)
    wtt = tot_wait_time / CONFIG.total_jobs
    wtt = round_three(wtt)
    print(f"WTT: {wtt} Seconds")

    tot_tut_time = Units.MiS_to_seconds(cpu_state.tut_rolling_time_sum)
    tut = tot_tut_time / CONFIG.total_jobs
    tut = round_three(tut)
    print(f"TUT: {tut} Seconds")