#ifndef TIMER_H #define TIMER_H #include #include class Timer { public: Timer(std::string const& message = "") : message{message}, start{std::steady_clock::now()} { } ~Timer() { std::cout << message << tock() << std::endl; } Timer(Timer const&) = delete; Timer(Timer&&) = delete; int tock() const { return std::duration_cast(std::steady_clock::now() - start).count(); } void tick() { start = std::steady_clock::now(); } private: std::string message; std::chrono::steady_clock::time_point start; }; #endif//TIMER_H