/* * Mirai. Copyright (C) 2024 Vyn * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only) * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt */ #ifndef CPP_UTILS_DEBUG_H #define CPP_UTILS_DEBUG_H #include #include #include #include #include namespace cpputils::debug { class Timer { public: Timer() : startTime(std::chrono::high_resolution_clock::now()) { } void start() { startTime = std::chrono::high_resolution_clock::now(); } void printTimeElapsed(const std::string &message) const { const auto now = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast(now - startTime); std::cout << "[Debug - Timer] " << message << ": " << ((double)duration.count() / 1000000) << " seconds" << std::endl; } private: std::chrono::time_point startTime; }; } // namespace cpputils::debug #endif