measure parsing and solve time

This commit is contained in:
Maximilian Keßler 2023-11-08 14:04:48 +01:00
parent 8de09bb38d
commit 34d19fcf46
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -1,9 +1,11 @@
#include <iostream> // For writing to the standard output. #include <iostream> // For writing to the standard output.
#include <fstream> // For reading input files. #include <fstream> // For reading input files.
#include <chrono>
#include "graph.hpp" #include "graph.hpp"
#include "edmonds.h" #include "edmonds.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if (argc != 2) if (argc != 2)
@ -16,10 +18,16 @@ int main(int argc, char** argv)
if (not input_file_graph.is_open()) { if (not input_file_graph.is_open()) {
throw std::runtime_error(std::string("Could not open file for reading: ") + argv[1]); throw std::runtime_error(std::string("Could not open file for reading: ") + argv[1]);
} }
auto start = std::chrono::high_resolution_clock::now();
ED::Graph graph = ED::Graph::read_dimacs(input_file_graph); ED::Graph graph = ED::Graph::read_dimacs(input_file_graph);
auto end = std::chrono::high_resolution_clock::now();
std::cout << "Parsing time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start) << std::endl;
// Now, calculate the matching // Now, calculate the matching
auto start2 = std::chrono::high_resolution_clock::now();
ED::Graph optimum_matching = Edmonds::maximum_matching(graph); ED::Graph optimum_matching = Edmonds::maximum_matching(graph);
auto end2 = std::chrono::high_resolution_clock::now();
std::cout << "Solving time: " << std::chrono::duration_cast<std::chrono::milliseconds>(end2 - start2) << std::endl;
std::cout << optimum_matching; std::cout << optimum_matching;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }