Show algorithm execution time
This commit is contained in:
parent
a81756e93b
commit
d04d0becfe
|
@ -2,6 +2,7 @@ from preprocessing import parse_file
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
from sys import argv
|
from sys import argv
|
||||||
from random import seed, randint
|
from random import seed, randint
|
||||||
|
from time import time
|
||||||
|
|
||||||
|
|
||||||
def get_first_solution(n, data):
|
def get_first_solution(n, data):
|
||||||
|
@ -72,13 +73,14 @@ def execute_algorithm(choice, n, m, data):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def show_results(solutions):
|
def show_results(solutions, time_delta):
|
||||||
distance_sum = solutions["distance"].sum()
|
distance_sum = solutions["distance"].sum()
|
||||||
duplicates = solutions.duplicated()
|
duplicates = solutions.duplicated()
|
||||||
print(solutions)
|
print(solutions)
|
||||||
print("Total distance: " + str(distance_sum))
|
print("Total distance: " + str(distance_sum))
|
||||||
if solutions[duplicates].empty:
|
if solutions[duplicates].empty:
|
||||||
print("No duplicates found")
|
print("No duplicates found")
|
||||||
|
print("Execution time: " + str(time_delta))
|
||||||
|
|
||||||
|
|
||||||
def usage(argv):
|
def usage(argv):
|
||||||
|
@ -93,8 +95,10 @@ def main():
|
||||||
if len(argv) != 3:
|
if len(argv) != 3:
|
||||||
usage(argv)
|
usage(argv)
|
||||||
n, m, data = parse_file(argv[1])
|
n, m, data = parse_file(argv[1])
|
||||||
|
start_time = time()
|
||||||
solutions = execute_algorithm(choice=argv[2], n=n, m=m, data=data)
|
solutions = execute_algorithm(choice=argv[2], n=n, m=m, data=data)
|
||||||
show_results(solutions)
|
end_time = time()
|
||||||
|
show_results(solutions, time_delta=end_time - start_time)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue