HIBF 1.0.0-rc.1
|
A timer with a thread-safe operator+=()
.
More...
#include <hibf/misc/timer.hpp>
Public Member Functions | |
Constructors, destructor and assignment | |
concurrent_timer ()=default | |
Defaulted. | |
concurrent_timer (concurrent_timer const &other) | |
Defaulted. | |
concurrent_timer & | operator= (concurrent_timer const &other) |
Defaulted. | |
concurrent_timer (concurrent_timer &&other) noexcept | |
Defaulted. | |
concurrent_timer & | operator= (concurrent_timer &&other) noexcept |
Defaulted. | |
~concurrent_timer ()=default | |
Defaulted. | |
Modification | |
void | start () |
Starts the timer. | |
void | stop () |
Stops the timer. | |
template<typename timer_t > requires (std::same_as<timer_t, serial_timer> || std::same_as<timer_t, concurrent_timer>) | |
void | operator+= (timer_t const &other) |
Adds another timer. | |
Access | |
double | in_seconds () const |
Returns the measured time in seconds. | |
double | max_in_seconds () const |
Returns the maximum measured time interval in seconds. | |
double | avg_in_seconds () const |
Returns the average measured time interval in seconds. | |
Comparison | |
constexpr bool | operator== (serial_timer const &) const |
Two timer are always equal. | |
constexpr bool | operator== (concurrent_timer const &) const |
Two timer are always equal. | |
Friends | |
class | serial_timer |
A timer with a thread-safe operator+=()
.
|
inline |
Starts the timer.
|
inline |
Stops the timer.
In Debug mode, an assertion checks that start()
has been called before.
|
inline |
Adds another timer.
This function is thread-safe.
|
inline |
Returns the measured time in seconds.
|
inline |
Returns the maximum measured time interval in seconds.
A time interval may be:
start()
and stop()
.operator+=()
.
|
inline |
Returns the average measured time interval in seconds.
A time interval may be:
start()
and stop()
.operator+=()
.The count used for averaging is the number of calls to stop()
and operator+=()
.
stop()
or operator+=()
have been used is undefined behaviour.
|
inlineconstexpr |
Two timer are always equal.
|
inlineconstexpr |
Two timer are always equal.