#pragma once // Timer.h #include /* * T is expected to be either: * std::chrono::system_clock or std::chrono::high_resolution_clock */ template class Timer { public: using time_point = std::chrono::time_point; using duration = std::chrono::duration; void start(); duration stop(); private: time_point _start; time_point _end; }; template void Timer::start() { _start = T::now(); } template typename Timer::duration Timer::stop() { _end = T::now(); return _end - _start; }