DOLFINx 0.10.0.0
DOLFINx C++ interface
|
Timer for measuring and logging elapsed time durations. More...
#include <Timer.h>
Public Member Functions | |
Timer (std::optional< std::string > task=std::nullopt) | |
Create and start timer. | |
~Timer () | |
void | start () |
Reset elapsed time and (re-)start timer. | |
template<typename Period = std::ratio<1>> | |
std::chrono::duration< double, Period > | elapsed () const |
Elapsed time since time has been started. | |
template<typename Period = std::ratio<1>> | |
std::chrono::duration< double, Period > | stop () |
Stop timer and return elapsed time. | |
void | resume () |
Resume a stopped timer. | |
void | flush () |
Flush timer duration to the logger. | |
Timer for measuring and logging elapsed time durations.
The basic usage is
The timer is started at construction and timing ends when the timer is destroyed (goes out-of-scope). The timer can be started (reset) and stopped explicitly by
A summary of registered elapsed times can be printed by calling:
Registered elapsed times are logged when (1) the timer goes out-of-scope or (2) Timer::flush() is called.
|
inline |
Create and start timer.
Elapsed time is optionally registered in the logger when the Timer destructor is called.
[in] | task | Name used to registered the elapsed time in the logger. If no name is set, the elapsed time is not registered in the logger. |
|
inline |
If timer is still running, it is stopped. Elapsed time is registered in the logger.
|
inline |
Elapsed time since time has been started.
Default duration unit is seconds.
|
inline |
Flush timer duration to the logger.
An instance of a timer can be flushed to the logger only once. Subsequent calls will have no effect and will not trigger any logging.
|
inline |
Resume a stopped timer.
Does nothing if timer has not been stopped.
|
inline |
Stop timer and return elapsed time.
Default duration unit is seconds.