Add execution time meand and standard deviation
This commit is contained in:
parent
b8b812d011
commit
5b63b993df
|
@ -14,33 +14,41 @@ def file_list(path):
|
||||||
|
|
||||||
|
|
||||||
def create_dataframes():
|
def create_dataframes():
|
||||||
greedy = DataFrame(columns=["dataset", "distancia", "desviacion"])
|
greedy = DataFrame()
|
||||||
local = DataFrame(columns=["dataset", "distancia", "desviacion"])
|
local = DataFrame()
|
||||||
return greedy, local
|
return greedy, local
|
||||||
|
|
||||||
|
|
||||||
def process_output(results):
|
def process_output(results):
|
||||||
distances = []
|
distances = []
|
||||||
|
time = []
|
||||||
for element in results:
|
for element in results:
|
||||||
for line in element:
|
for line in element:
|
||||||
if line.startswith(bytes("Total distance:", encoding="utf-8")):
|
if line.startswith(bytes("Total distance:", encoding="utf-8")):
|
||||||
line_elements = line.split(sep=bytes(":", encoding="utf-8"))
|
line_elements = line.split(sep=bytes(":", encoding="utf-8"))
|
||||||
distances.append(float(line_elements[1]))
|
distances.append(float(line_elements[1]))
|
||||||
return distances
|
if line.startswith(bytes("Execution time:", encoding="utf-8")):
|
||||||
|
line_elements = line.split(sep=bytes(":", encoding="utf-8"))
|
||||||
|
time.append(float(line_elements[1]))
|
||||||
|
return distances, time
|
||||||
|
|
||||||
|
|
||||||
def populate_dataframes(greedy, local, greedy_list, local_list, dataset):
|
def populate_dataframes(greedy, local, greedy_list, local_list, dataset):
|
||||||
greedy_results = process_output(greedy_list)
|
greedy_distances, greedy_time = process_output(greedy_list)
|
||||||
local_results = process_output(local_list)
|
local_distances, local_time = process_output(local_list)
|
||||||
greedy_dict = {
|
greedy_dict = {
|
||||||
"dataset": dataset.removeprefix("data/"),
|
"dataset": dataset.removeprefix("data/"),
|
||||||
"distancia": mean(greedy_results),
|
"media distancia": mean(greedy_distances),
|
||||||
"desviacion": std(greedy_results),
|
"desviacion distancia": std(greedy_distances),
|
||||||
|
"media tiempo": mean(greedy_time),
|
||||||
|
"desviacion tiempo": std(greedy_time),
|
||||||
}
|
}
|
||||||
local_dict = {
|
local_dict = {
|
||||||
"dataset": dataset.removeprefix("data/"),
|
"dataset": dataset.removeprefix("data/"),
|
||||||
"distancia": mean(local_results),
|
"media distancia": mean(local_distances),
|
||||||
"desviacion": std(local_results),
|
"desviacion distancia": std(local_distances),
|
||||||
|
"media tiempo": mean(local_time),
|
||||||
|
"desviacion tiempo": std(local_time),
|
||||||
}
|
}
|
||||||
greedy = greedy.append(greedy_dict, ignore_index=True)
|
greedy = greedy.append(greedy_dict, ignore_index=True)
|
||||||
local = local.append(local_dict, ignore_index=True)
|
local = local.append(local_dict, ignore_index=True)
|
||||||
|
@ -76,13 +84,17 @@ def export_results(greedy, local):
|
||||||
worksheet = writer.sheets[name]
|
worksheet = writer.sheets[name]
|
||||||
for index, column in enumerate(df):
|
for index, column in enumerate(df):
|
||||||
series = df[column]
|
series = df[column]
|
||||||
max_length = series.astype(str).str.len().max()
|
max_length = max(series.astype(str).str.len().max(), len(str(series.name)))
|
||||||
worksheet.set_column(index, index, width=max_length + 5)
|
worksheet.set_column(index, index, width=max_length + 5)
|
||||||
writer.save()
|
writer.save()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
datasets = file_list(path="data/*.txt")
|
datasets = file_list(path="data/*.txt")
|
||||||
greedy, local = create_dataframes()
|
greedy, local = create_dataframes()
|
||||||
populated_greedy, populated_local = script_execution(datasets, greedy, local)
|
populated_greedy, populated_local = script_execution(datasets, greedy, local)
|
||||||
export_results(populated_greedy, populated_local)
|
export_results(populated_greedy, populated_local)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue