11#ifndef __BE_TIME_TIMER_H__
12#define __BE_TIME_TIMER_H__
44 std::chrono::monotonic_clock;
46 std::chrono::steady_clock;
63 const std::function<
void()> &func);
124 bool displayUnits =
false,
144 const std::function<
void()> &func);
154 BE_CLOCK_TYPE::time_point _start;
156 BE_CLOCK_TYPE::time_point _finish;
This class can be used by applications to report the amount of time a block of code takes to execute.
Timer(const std::function< void()> &func)
Construct a timer and time a function immediately.
void stop()
Stop tracking time.
Timer()
Constructor for the Timer object.
std::string elapsedStr(bool displayUnits=false, bool nano=false) const
Convenience method for printing elapsed time as a string.
void start()
Start tracking time.
std::chrono::steady_clock BE_CLOCK_TYPE
Clock type to use, aliased for easy replacement.
uint64_t elapsed(bool nano=false) const
Get the elapsed time in microseconds or nanoseconds between calls to this object's start() and stop()...
Timer & time(const std::function< void()> &func)
Record the runtime of a function.
std::ostream & operator<<(std::ostream &s, const Timer &timer)
Output stream operator overload for Timer.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...