diff --git a/2023/xmaslib/solution/solution.cpp b/2023/xmaslib/solution/solution.cpp index 45f085a..410b183 100644 --- a/2023/xmaslib/solution/solution.cpp +++ b/2023/xmaslib/solution/solution.cpp @@ -1,25 +1,35 @@ #include "solution.hpp" +#include #include #include #include #include #include +#include + namespace xmas { void solution::run() { std::cout << "Day 1" << std::endl; + try { - const auto p1 = this->part1(); - std::cout << " Result 1: " << p1 << '\n'; + const auto start = std::chrono::high_resolution_clock::now(); + const auto result = this->part1(); + const auto elapsed = std::chrono::high_resolution_clock::now() - start; + + std::cout << std::format(" Result 1: {} ({} μs)\n", result, std::chrono::duration_cast(elapsed).count()); } catch (std::runtime_error &err) { std::cerr << "Part 1 failed with message: " << err.what() << std::endl; } try { - const auto p2 = this->part2(); - std::cout << " Result 2: " << p2 << '\n'; + const auto start = std::chrono::high_resolution_clock::now(); + const auto result = this->part2(); + const auto elapsed = std::chrono::high_resolution_clock::now() - start; + + std::cout << std::format(" Result 2: {} ({} μs)\n", result, std::chrono::duration_cast(elapsed).count()); } catch (std::runtime_error &err) { std::cerr << "Part 2 failed with message: " << err.what() << std::endl; }