From c95461f7ed21d2063b634d2336eaf4426da672f7 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Fri, 6 Sep 2024 16:22:59 +0200 Subject: [PATCH] took --- src/tsp.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tsp.cpp b/src/tsp.cpp index cca9c71..0241663 100755 --- a/src/tsp.cpp +++ b/src/tsp.cpp @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - string filename = "tsp10.txt"; + string filename = "tsp1000.txt"; #ifdef __APPLE__ // On macOS the resources are copeied to build// // whilst, the running binary is under build//TSP.app/Contents/MacOS/ @@ -46,22 +46,25 @@ int main(int argc, char *argv[]) { Tour tour; double x; double y; + auto timeStart = std::chrono::high_resolution_clock::now(); while (input >> x >> y) { Point p(x, y); tour.insertNearest(p); //uncomment the 4 lines below to animate - tour.draw(scene); - std::chrono::milliseconds dura(50); - std::this_thread::sleep_for(dura); - a.processEvents(); + //tour.draw(scene); + //std::chrono::milliseconds dura(50); + //std::this_thread::sleep_for(dura); + //a.processEvents(); } input.close(); + auto took = std::chrono::high_resolution_clock::now() - timeStart; // print tour to standard output cout << "Tour distance: " << std::fixed << std::setprecision(4) << std::showpoint << tour.distance() << endl; cout << "Number of points: " << tour.size() << endl; tour.show(); + cout << "Calculation took: " << took.count()*1E-6 << "ms" << endl; // draw tour tour.draw(scene);