/** * @file debugTimes.h * @author Alexander Klein (alex@kleiax.de) * @brief Inherits a class to measure times of functions. * @version 0.1 * @date 2021-12-13 * * @copyright Copyright (c) 2021 * */ #ifndef DEBUG_TIMES_H #define DEBUG_TIMES_H #include #include #include /** * @brief A class to measure times of functions. * * This simple class only save the value of the millis() * function when you call the constructor or restart(). * To get the elapsed time call stop() or stopConsol(). * * @warning This class is not very accurate * It only give you the time in milliseconds. */ class DebugTimes { public: /** * @brief Construct a new Debug Times object * Starts to count milliseconds */ DebugTimes(); /** * @brief Set the counter to 0 */ void restart(); /** * @brief Give the elapsed time * * @return uint16_t elapsed milliseconds */ uint16_t stop(); /** * @brief Print the elapsed time to consol * * @param name Functionname to print * @param minTime A minimum time before printing */ void stopConsol(const char* name, uint16_t minTime = 0); private: uint64_t startTime; }; #endif //DEBUG_TIMES_H