Management of a timer. More...
#include <arcane/core/Timer.h>
Classes | |
| class | Sentry |
| Sentinel for the timer. The sentinel associated with a timer allows it to be triggered upon its construction and stopped upon its destruction. This ensures that the timer will be properly stopped in case of an exception, for example. More... | |
| class | Action |
| Positions the name of the currently executing action. More... | |
| class | Phase |
| Positions the phase of the currently executing action. More... | |
| class | SimplePrinter |
| Displays the time elapsed between the call to the constructor and the destructor. More... | |
Public Types | |
| enum | eTimerType { TimerVirtual , TimerReal } |
| Timer type. More... | |
Public Member Functions | |
| Timer (ISubDomain *sd, const String &name, eTimerType type) | |
| Constructs a timer. | |
| Timer (ITimerMng *tm, const String &name, eTimerType type) | |
| Constructs a timer. | |
| ~Timer () | |
| Frees resources. | |
| void | start () |
| Activates the timer. | |
| Real | stop () |
| Deactivates the timer. | |
| bool | isActivated () const |
| Returns the activation status of the timer. | |
| const String & | name () const |
| Returns the name of the timer. | |
| Real | totalTime () const |
| Returns the total time (in seconds) spent in the timer. | |
| Real | lastActivationTime () const |
| Returns the time (in seconds) spent during the last activation of the timer. | |
| Integer | nbActivated () const |
| Returns the number of times the timer has been activated. | |
| eTimerType | type () const |
| Returns the type of time used. | |
| void | reset () |
| Resets the time counters. | |
| ITimerMng * | timerMng () const |
| Manager associated with this timer. | |
| void | _setStartTime (Real t) |
| Real | _startTime () const |
Static Public Member Functions | |
| static TimeMetricAction | phaseAction (ITimeStats *s, eTimePhase phase) |
Private Attributes | |
| ITimerMng * | m_timer_mng |
| Timer manager. | |
| eTimerType | m_type |
| Timer type. | |
| Integer | m_nb_activated |
| Number of times the timer has been activated. | |
| bool | m_is_activated |
| true if the timer is active | |
| Real | m_activation_time |
| Time spent during the last activation. | |
| Real | m_total_time |
| Total time spent in the timer. | |
| String | m_name |
| Timer name. | |
| Real | m_start_time |
| Time of the start of the last activation. | |
Management of a timer.
An instance of this class allows measuring the time elapsed between its activation via the start() method and its stopping via the stop() method.
The timer can be used multiple times, and it is possible to know both the number of activations (nbActivated()) and the total time spent in its successive activations (totalTime()).
There are two operating modes:
The timer resolution depends on the machine. It is on the order of milliseconds for timers using CPU time and on the order of microseconds for timers using real time.
| Arcane::Timer::Timer | ( | ISubDomain * | sd, |
| const String & | name, | ||
| eTimerType | type ) |
Constructs a timer.
Constructs a timer linked to the sub-domain sd, with name name and type type.
Definition at line 36 of file Timer.cc.
References name(), Timer(), timerMng(), and type().
Referenced by Arcane::Timer::Sentry::Sentry(), and Timer().
| Arcane::Timer::Timer | ( | ITimerMng * | tm, |
| const String & | name, | ||
| eTimerType | type ) |
Constructs a timer.
Constructs a timer linked to the manager tm, with name name and type type.
Definition at line 45 of file Timer.cc.
References m_activation_time, m_is_activated, m_name, m_nb_activated, m_start_time, m_timer_mng, m_total_time, m_type, name(), and type().
|
inline |
Definition at line 264 of file Timer.h.
References m_start_time.
Referenced by Arcane::TimerMng::beginTimer().
|
inline |
Definition at line 266 of file Timer.h.
References m_start_time.
Referenced by Arcane::TimerMng::endTimer(), and Arcane::TimerMng::getTime().
|
inline |
Returns the activation status of the timer.
Definition at line 234 of file Timer.h.
References m_is_activated.
Referenced by Arcane::TimerMng::hasTimer().
|
inline |
Returns the time (in seconds) spent during the last activation of the timer.
Definition at line 243 of file Timer.h.
References m_activation_time.
Referenced by Arcane::TimeLoopMng::_doMeshPartition(), Arcane::LimaCutInfosReader::_readUniqueIndex(), Arcane::mesh::DynamicMesh::allocateCells(), Arcane::mesh::DynamicMeshKindInfos::beginCompactItems(), Arcane::ArcaneInitialPartitioner::partitionAndDistributeMeshes(), Arcane::mesh::DynamicMesh::reloadMesh(), and Arcane::Materials::ItemMaterialVariableScalar< DataType >::synchronize().
|
inline |
|
inline |
Returns the number of times the timer has been activated.
Definition at line 246 of file Timer.h.
References m_nb_activated.
|
static |
| void Arcane::Timer::reset | ( | ) |
Resets the time counters.
Definition at line 99 of file Timer.cc.
References m_activation_time, m_is_activated, and m_total_time.
| void Arcane::Timer::start | ( | ) |
Activates the timer.
If the timer is already active, this method does nothing.
Definition at line 69 of file Timer.cc.
References ARCANE_FATAL, m_activation_time, m_is_activated, m_nb_activated, and m_timer_mng.
Referenced by Arcane::ArcaneBasicMeshSubdividerService::subdivideMesh().
| Real Arcane::Timer::stop | ( | ) |
Deactivates the timer.
If the timer is not active at the time of the call, this method does not do anything.
Definition at line 86 of file Timer.cc.
References ARCANE_FATAL, m_activation_time, m_is_activated, m_timer_mng, and m_total_time.
Referenced by Arcane::ArcaneBasicMeshSubdividerService::subdivideMesh().
|
inline |
Manager associated with this timer.
Definition at line 255 of file Timer.h.
References m_timer_mng.
Referenced by Arcane::TimerMng::hasTimer(), and Timer().
|
inline |
Returns the total time (in seconds) spent in the timer.
Definition at line 240 of file Timer.h.
References m_total_time.
Referenced by Arcane::ArcaneBasicMeshSubdividerService::subdivideMesh().
|
inline |
|
private |
|
private |
|
private |
|
private |
Number of times the timer has been activated.
Definition at line 272 of file Timer.h.
Referenced by nbActivated(), start(), and Timer().
|
private |
Time of the start of the last activation.
Definition at line 277 of file Timer.h.
Referenced by _setStartTime(), _startTime(), and Timer().
|
private |
|
private |
|
private |