33 template<
typename ResolutionType,
typename ClockType = std::chrono::steady_clock>
38 using point =
typename clock::time_point;
81 return clock::now() -
start_;
94 template<
typename OpTimerType>
95 inline std::ostream&
operator<<(std::ostream& o,
const OpTimerType& tm)
97 o << std::chrono::duration_cast<typename OpTimerType::resolution>(tm.elapsed()).count();
point start() const
Returns the start time point.
typename clock::duration interval
optimer(report_callback f=report_callback{})
Constructor, which starts the timer.
Reports time elapsed at the end of an object scope.
std::ostream & operator<<(std::ostream &o, const OpTimerType &tm)
Formats time elapsed for writing to a stream.
~optimer()
Destructor, which invokes the report callback.
interval elapsed() const
Returns the elapsed time value.
std::function< void(const optimer &)> report_callback
void reset()
Resets the timer back to zero.
ResolutionType resolution