NamedTimer< Name, Scope > Class Template Reference
|
CPP API
|
Thread local singleton timer, identified by its name. Best used via AutoTimer. More...
#include <named_timer.h>
Public Member Functions | |
| NamedTimer (NamedTimer &&)=delete | |
| NamedTimer (NamedTimer &)=delete | |
| Do not allow construction other than through get_instance and the default constructor. More... | |
Public Member Functions inherited from mio::timing::BasicTimer | |
| DurationType | get_elapsed_time () const |
| Get the total time spent between starts and stops. Only call while the timer is stopped. More... | |
| void | reset () |
| Set the elapsed time to 0. Only call while the timer is stopped. More... | |
| template<class IOContext > | |
| void | serialize (IOContext &io) const |
| serialize this. More... | |
| void | start () |
| Start the timer. Must be followed by exactly one stop. More... | |
| void | stop () |
| Stop the timer and update the elapsed time. After calling stop, the timer may be started again. More... | |
| ~BasicTimer () | |
Static Public Member Functions | |
| static NamedTimer & | get_instance () |
| Get a thread local instance of this timer. More... | |
| static std::string | name () |
| Get the timer's name as a runtime string. More... | |
| static std::string | scope () |
| Get the timer's scope as a runtime string. More... | |
Static Public Member Functions inherited from mio::timing::BasicTimer | |
| template<class IOContext > | |
| static IOResult< BasicTimer > | deserialize (IOContext &io) |
| deserialize an object of this class. More... | |
Private Member Functions | |
| NamedTimer () | |
| Create a NamedTimer and register it. More... | |
Detailed Description
template<StringLiteral Name, StringLiteral Scope = "">
class mio::timing::NamedTimer< Name, Scope >
Thread local singleton timer, identified by its name. Best used via AutoTimer.
Constructor & Destructor Documentation
◆ NamedTimer() [1/3]
|
delete |
Do not allow construction other than through get_instance and the default constructor.
◆ NamedTimer() [2/3]
|
delete |
◆ NamedTimer() [3/3]
|
inlineprivate |
Create a NamedTimer and register it.
Since this is the only available constructor, and the registration is made before construction is done, it is guaranteed (by standard), that NamedTimer is destroyed after TimerRegistrar. See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf 15.6.2 and 15.4-9.
Member Function Documentation
◆ get_instance()
|
inlinestatic |
Get a thread local instance of this timer.
It is automatically registered to the TimerRegistrar.
This is the only way to obtain a NamedTimer, as its constructors are disabled. Since there is exactly one timer for each Name and Scope combination, this timer is inherently threadsafe. The Name and Scope together effectively work as a key for a global map, though the map access is made during compilation.
◆ name()
|
inlinestatic |
Get the timer's name as a runtime string.
◆ scope()
|
inlinestatic |
Get the timer's scope as a runtime string.
Generated by
Public Member Functions inherited from