49 using TimePoint = std::chrono::time_point<ChronoClock>;
67 explicit Timer(
const std::string& inName) :
93 std::this_thread::sleep_for(TimeUnit(length));
102 start_ = ChronoClock::now();
115 const auto duration = std::chrono::duration_cast<TimeUnit>(ChronoClock::now() - start_);
119 std::cout << name_ <<
"Elapsed Time = " << duration.count() << unit_ << std::endl;
127 std::string name_{
"" };
128 std::string unit_{
"" };
133 if constexpr (std::is_same_v<TimeUnit, std::chrono::hours>)
137 else if constexpr (std::is_same_v<TimeUnit, std::chrono::minutes>)
141 else if constexpr (std::is_same_v<TimeUnit, std::chrono::seconds>)
145 else if constexpr (std::is_same_v<TimeUnit, std::chrono::milliseconds>)
147 unit_ =
" milliseconds";
149 else if constexpr (std::is_same_v<TimeUnit, std::chrono::microseconds>)
151 unit_ =
" microseconds";
153 else if constexpr (std::is_same_v<TimeUnit, std::chrono::nanoseconds>)
155 unit_ =
" nanoseconds";
159 unit_ =
" time units of some sort";