Commit 2b3f5e66 authored by iker_martin's avatar iker_martin
Browse files

Rama Analysis - Refactor a nuevo sistema de ficheros

parent b5d18427
...@@ -45,6 +45,85 @@ def record(f, observation, line): ...@@ -45,6 +45,85 @@ def record(f, observation, line):
#else: #else:
# getData(lineS, observation, 13) # getData(lineS, observation, 13)
# Obtains the value of a given index in a splited line
# and returns it as a float values
def get_value(line, index):
return float(line[index].split('=')[1].split(',')[0])
# Obtains the general parameters of an execution and
# stores them for creating a dataframe
def record_config_line(lineS, dataA, dataB):
dataA.append([None]*13)
dataB.append([None]*15)
resizes = int(get_value(lineS, 2))
stages = int(get_value(lineS, 3))
compute_tam = int(get_value(lineS, 4))
sdr = int(get_value(lineS, 5))
adr = int(get_value(lineS, 6)) #TODO Que lo tome como porcentaje
at = int(get_value(lineS, 7))
sm = int(get_value(lineS, 8))
ss = int(get_value(lineS, 9))
latency = get_value(lineS, 10)
bw = get_value(lineS, 11)
dataB[it][0] = sdr
dataB[it][1] = adr
dataB[it][4] = ""
dataB[it][5] = compute_tam
dataB[it][6] = comm_tam
dataB[it][7] = cst
dataB[it][8] = css
dataB[it][9] = time
dataB[it][10] = ""
dataA[it][0] = sdr
dataA[it][1] = adr
dataA[it][5] = ""
dataA[it][6] = compute_tam
dataA[it][7] = comm_tam
dataA[it][8] = cst
dataA[it][9] = css
dataA[it][10] = time
dataA[it][11] = ""
def record_stage_line(lineS, dataG_it, dataM_it):
pt = int(get_value(lineS, 2))
t_stage = get_value(lineS, 3)
u_bytes = int(get_value(lineS, 4))
dataG_it[].append(pt)
dataG_it[].append(t_stage)
dataG_it[].append(u_bytes)
dataM_it[].append(pt)
dataM_it[].append(t_stage)
dataM_it[].append(u_bytes)
def record_resize_line(lineS, dataG_it, dataM_it):
iters = int(lineS[2].split('=')[1].split(',')[0])
npr = int(lineS[3].split('=')[1].split(',')[0])
dist = lineS[5].split('=')[1]
resizes = resizes - 1
if resizes == 0:
dataB[it][3] = npr
dataB[it][4] += dist
dataB[it][10] += str(iters)
dataA[it][4] = npr #FIXME No sera correcta si hay mas de una reconfig
dataA[it][2] = str(previousNP) + "," + str(npr)
dataA[it][5] += dist
dataA[it][11] += str(iters)
timer = 4
else:
dataB[it][2] = npr
dataB[it][4] += dist + ","
dataB[it][10] += str(iters) + ","
dataA[it][3] = npr
dataA[it][5] += dist + ","
dataA[it][11] += str(iters) + ","
previousNP = npr
#----------------------------------------------- #-----------------------------------------------
def read_file(f, dataA, dataB, it): def read_file(f, dataA, dataB, it):
...@@ -60,39 +139,11 @@ def read_file(f, dataA, dataB, it): ...@@ -60,39 +139,11 @@ def read_file(f, dataA, dataB, it):
if lineS[0] == "Config": # CONFIG LINE if lineS[0] == "Config": # CONFIG LINE
recording = True recording = True
it += 1 it += 1
dataA.append([None]*13) record_config(lineS, dataG, dataM)
dataB.append([None]*15)
#resizes = int(lineS[2].split('=')[1].split(',')[0])
resizes = 2
compute_tam = int(lineS[3].split('=')[1].split(',')[0])
comm_tam = int(lineS[4].split('=')[1].split(',')[0])
sdr = int(lineS[5].split('=')[1].split(',')[0])
adr = int(lineS[6].split('=')[1].split(',')[0]) #TODO Que lo tome como porcentaje
css = int(lineS[8].split('=')[1].split(',')[0])
cst = int(lineS[9].split('=')[1].split(',')[0])
# TODO Que obtenga Aib
time = float(lineS[10].split('=')[1])
dataB[it][0] = sdr
dataB[it][1] = adr
dataB[it][4] = ""
dataB[it][5] = compute_tam
dataB[it][6] = comm_tam
dataB[it][7] = cst
dataB[it][8] = css
dataB[it][9] = time
dataB[it][10] = ""
dataA[it][0] = sdr
dataA[it][1] = adr
dataA[it][5] = ""
dataA[it][6] = compute_tam
dataA[it][7] = comm_tam
dataA[it][8] = cst
dataA[it][9] = css
dataA[it][10] = time
dataA[it][11] = ""
elif lineS[0] == "Stage":
record_stage_line(lineS, dataG, dataM)
elif lineS[0] == "Resize":
elif recording and resizes != 0: # RESIZE LINE elif recording and resizes != 0: # RESIZE LINE
iters = int(lineS[2].split('=')[1].split(',')[0]) iters = int(lineS[2].split('=')[1].split(',')[0])
npr = int(lineS[3].split('=')[1].split(',')[0]) npr = int(lineS[3].split('=')[1].split(',')[0])
...@@ -165,26 +216,27 @@ else: ...@@ -165,26 +216,27 @@ else:
insideDir = "Run" insideDir = "Run"
lista = glob.glob("./" + BaseDir + insideDir + "*/" + sys.argv[1]+ "*Global.o*") lista = glob.glob("./" + BaseDir + insideDir + "*/" + sys.argv[1]+ "*Global.o*")
lista += (glob.glob("./" + BaseDir + sys.argv[1]+ "*Global.o*")) # Se utiliza cuando solo hay un nivel de directorios
print("Number of files found: "+ str(len(lista))); print("Number of files found: "+ str(len(lista)));
it = -1 it = -1
dataA = [] dataG = []
dataB = [] dataM = []
columnsA = ["N", "%Async", "Groups", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TE"] #13 columnsG = ["N", "%Async", "Groups", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TE"] #13
columnsB = ["N", "%Async", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TC", "TH", "TS", "TA"] #15 columnsM = ["N", "%Async", "NP", "NS", "Dist", "Matrix", "CommTam", "Cst", "Css", "Time", "Iters", "TC", "TH", "TS", "TA"] #15
for elem in lista: for elem in lista:
f = open(elem, "r") f = open(elem, "r")
it = read_file(f, dataA, dataB, it) it = read_file(f, dataG, dataM, it)
f.close() f.close()
#print(data) #print(data)
dfA = pd.DataFrame(dataA, columns=columnsA) dfG = pd.DataFrame(dataG, columns=columnsG)
dfA.to_csv(name + 'G.csv') dfG.to_csv(name + 'G.csv')
dfB = pd.DataFrame(dataB, columns=columnsB) dfM = pd.DataFrame(dataM, columns=columnsM)
#Poner en TC el valor real y en TH el necesario para la app #Poner en TC el valor real y en TH el necesario para la app
cond = dfB.TH != 0 cond = dfM.TH != 0
dfB.loc[cond, ['TC', 'TH']] = dfB.loc[cond, ['TH', 'TC']].values dfM.loc[cond, ['TC', 'TH']] = dfB.loc[cond, ['TH', 'TC']].values
dfB.to_csv(name + 'M.csv') dfM.to_csv(name + 'M.csv')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment