import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from constants import titles TASK_COMP_CONF_LOG = "Task {} has all requirements fullfilled" SEC_TO_MIN = 60 NS_TO_US = 1000 #NS_TO_MS = 1000000 def get_elapsed_time(conf_folder): return round(pd.read_csv(conf_folder+"/elapsed_time.txt", delimiter=":", header=None).iloc[0,1]/SEC_TO_MIN, 2) def get_throt_perc(conf_folder): throt_cnt = pd.read_csv(conf_folder+"/throttled_count.csv" ).sum().loc["throttled_count"] pckt_cnt = pd.read_csv(conf_folder+"/packet_count.csv" ).sum().loc["packet_count"] return round(100*throt_cnt/pckt_cnt, 2) def get_sim_time(conf_folder): with open(conf_folder+"/pe_tasks.log", "r") as f: sim_time = int(f.readlines()[-1].strip().split(":")[0][:-3])/NS_TO_US #sim_time = sim_time/NS_TO_MS if sim_time > NS_TO_MS else sim_time/NS_TO_US #sim_time = sim_time/NS_TO_US return round(sim_time, 2) def get_conf_time(conf_folder, final_conf_task): conf_line = TASK_COMP_CONF_LOG.format(final_conf_task) with open(conf_folder+"/pe_tasks.log", "r") as f: comp_conf_line = [line for line in f.readlines() if conf_line in line] conf_time = int(comp_conf_line[0].strip().split(":")[0][:-3])/NS_TO_US return round(conf_time, 2) def normalize_sim_time(sim_time_table): col = "execution time" sim_time_col = sim_time_table[col] sim_time_col = sim_time_col/sim_time_col.iloc[0] sim_time_table.loc[:,col] = sim_time_col return sim_time_table def normalize_conf_time(conf_time_table): col = "configuration time" conf_time_col = conf_time_table[col] conf_time_col = conf_time_col/conf_time_col.max() conf_time_table.loc[:,col] = conf_time_col return conf_time_table def generate_throttle_graph(throt_table, model): ax = sns.barplot(throt_table, x="noc architecture", y="throttled percentage", hue="noc architecture", palette="Blues") ax.set_title(titles[model] + " - Throttle percentage") for container in ax.containers: ax.bar_label(container, fontsize=10) plt.savefig("throttled_perc_"+model+".png") with open('results.txt', 'a') as f: print(throt_table, file=f) plt.clf() def generate_sim_time_graph(sim_time_table, model): ax = sns.barplot(sim_time_table, x="noc architecture", y="execution time", hue="noc architecture", palette="Blues") ax.set_title(titles[model]+" - Normalized execution time") for container in ax.containers: ax.bar_label(container, fontsize=10) plt.savefig("execution_time_"+model+".png") with open('results.txt', 'a') as f: print(sim_time_table, file=f) plt.clf() def generate_el_time_graph(el_tim_table, model): ax = sns.barplot(el_tim_table, x="noc architecture", y="elapsed time", hue="noc architecture", palette="Blues") ax.set_title(titles[model]+" - Computation time (min)") for container in ax.containers: ax.bar_label(container, fontsize=10) plt.savefig("elapsed_time_"+model+".png") with open('results.txt', 'a') as f: print(el_tim_table, file=f) plt.clf() def generate_conf_time_graph(conf_table, model): ax = sns.barplot(conf_table, x="noc architecture", y="configuration time", hue="noc architecture", palette="Blues") ax.set_title("Circuit switching configuration time over total simulation time") for container in ax.containers: ax.bar_label(container, fontsize=10) plt.savefig("configuration_time_"+model+".png") with open('results.txt', 'a') as f: print(conf_table, file=f) plt.clf()