This class can be used by applications to report the amount of time a block of code takes to execute.
More...
#include <be_time_timer.h>
|
| using | BE_CLOCK_TYPE = std::chrono::steady_clock |
| | Clock type to use, aliased for easy replacement. More...
|
| |
|
| | Timer () |
| | Constructor for the Timer object. More...
|
| |
| | Timer (const std::function< void()> &func) |
| | Construct a timer and time a function immediately. More...
|
| |
| void | start () |
| | Start tracking time. More...
|
| |
| void | stop () |
| | Stop tracking time. More...
|
| |
| uint64_t | elapsed (bool nano=false) const |
| | Get the elapsed time in microseconds or nanoseconds between calls to this object's start() and stop() methods. More...
|
| |
| std::string | elapsedStr (bool displayUnits=false, bool nano=false) const |
| | Convenience method for printing elapsed time as a string. More...
|
| |
| Timer & | time (const std::function< void()> &func) |
| | Record the runtime of a function. More...
|
| |
This class can be used by applications to report the amount of time a block of code takes to execute.
Applcations wrap the block of code in the Timer::start() and Timer::stop() calls, then use Timer::elapsed() to obtain the calculated time of the operation.
- Warning
- Timers are not threadsafe and should only be used to time operations within the same thread.
Definition at line 38 of file be_time_timer.h.
◆ BE_CLOCK_TYPE
Clock type to use, aliased for easy replacement.
Definition at line 42 of file be_time_timer.h.
◆ Timer() [1/2]
| BiometricEvaluation::Time::Timer::Timer |
( |
| ) |
|
Constructor for the Timer object.
◆ Timer() [2/2]
| BiometricEvaluation::Time::Timer::Timer |
( |
const std::function< void()> & |
func | ) |
|
Construct a timer and time a function immediately.
- Parameters
-
| func | A function to time immediately. |
- Exceptions
-
◆ start()
| void BiometricEvaluation::Time::Timer::start |
( |
| ) |
|
Start tracking time.
- Exceptions
-
| Error::StrategyError | This object is currently timing an operation or an error occurred when obtaining timing information. |
◆ stop()
| void BiometricEvaluation::Time::Timer::stop |
( |
| ) |
|
Stop tracking time.
- Exceptions
-
| Error::StrategyError | This object is not currently timing an operation or an error occurred when obtaining timing information. |
◆ elapsed()
| uint64_t BiometricEvaluation::Time::Timer::elapsed |
( |
bool |
nano = false | ) |
const |
Get the elapsed time in microseconds or nanoseconds between calls to this object's start() and stop() methods.
- Parameters
-
| nano | True if to return nanoseconds, false otherwise. |
- Returns
- The number of microseconds or nanoseconds.
- Exceptions
-
| Error::StrategyError | This object is currently timing an operation or an error occurred when obtaining timing information. |
◆ elapsedStr()
| std::string BiometricEvaluation::Time::Timer::elapsedStr |
( |
bool |
displayUnits = false, |
|
|
bool |
nano = false |
|
) |
| const |
Convenience method for printing elapsed time as a string.
- Parameters
-
| displayUnits | Append the elapsed time units. |
| nano | True if to return nanoseconds, false otherwise. |
- Returns
- String representing the elapsed time.
- Exceptions
-
◆ time()
| Timer & BiometricEvaluation::Time::Timer::time |
( |
const std::function< void()> & |
func | ) |
|
Record the runtime of a function.
- Parameters
-
- Returns
- Reference to this class.
- Exceptions
-
The documentation for this class was generated from the following file: