Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::Timer Class Reference

Management of a timer. More...

#include <arcane/core/Timer.h>

Collaboration diagram for Arcane::Timer:

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 Stringname () 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.
ITimerMngtimerMng () 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

ITimerMngm_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.

Detailed Description

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:

  • TimerVirtual: the timer uses the CPU time of the process. This time is constant regardless of the machine load;
  • TimerReal: the timer uses real time. The resolution of this timer is generally better than with the previous type, but it is only significant when the machine is dedicated to the process.
Note
Since version 3.6 of Arcane, TimerVirtual is obsolete and the returned value will be equivalent to TimerReal.

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.

Definition at line 62 of file Timer.h.

Member Enumeration Documentation

◆ eTimerType

Timer type.

Enumerator
TimerVirtual 

Timer using CPU time (obsolete).

Deprecated
This timer is no longer used and behaves like the clock time (TimerReal).
TimerReal 

Timer using real time.

Definition at line 67 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer() [1/2]

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Timer() [2/2]

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().

Here is the call graph for this function:

◆ ~Timer()

Arcane::Timer::~Timer ( )

Frees resources.

Definition at line 61 of file Timer.cc.

Member Function Documentation

◆ _setStartTime()

void Arcane::Timer::_setStartTime ( Real t)
inline

Definition at line 264 of file Timer.h.

References m_start_time.

Referenced by Arcane::TimerMng::beginTimer().

Here is the caller graph for this function:

◆ _startTime()

Real Arcane::Timer::_startTime ( ) const
inline

Definition at line 266 of file Timer.h.

References m_start_time.

Referenced by Arcane::TimerMng::endTimer(), and Arcane::TimerMng::getTime().

Here is the caller graph for this function:

◆ isActivated()

bool Arcane::Timer::isActivated ( ) const
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().

Here is the caller graph for this function:

◆ lastActivationTime()

Real Arcane::Timer::lastActivationTime ( ) const
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().

Here is the caller graph for this function:

◆ name()

const String & Arcane::Timer::name ( ) const
inline

Returns the name of the timer.

Definition at line 237 of file Timer.h.

References m_name.

Referenced by Arcane::ArcaneBasicMeshSubdividerService::subdivideMesh(), Timer(), and Timer().

Here is the caller graph for this function:

◆ nbActivated()

Integer Arcane::Timer::nbActivated ( ) const
inline

Returns the number of times the timer has been activated.

Definition at line 246 of file Timer.h.

References m_nb_activated.

◆ phaseAction()

TimeMetricAction Arcane::Timer::phaseAction ( ITimeStats * s,
eTimePhase phase )
static

Definition at line 267 of file Timer.cc.

◆ reset()

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.

◆ start()

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().

Here is the caller graph for this function:

◆ stop()

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.

Returns
the time elapsed (in seconds) since the last activation.

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().

Here is the caller graph for this function:

◆ timerMng()

ITimerMng * Arcane::Timer::timerMng ( ) const
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().

Here is the caller graph for this function:

◆ totalTime()

Real Arcane::Timer::totalTime ( ) const
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().

Here is the caller graph for this function:

◆ type()

eTimerType Arcane::Timer::type ( ) const
inline

Returns the type of time used.

Definition at line 249 of file Timer.h.

References m_type.

Referenced by Timer(), and Timer().

Here is the caller graph for this function:

Member Data Documentation

◆ m_activation_time

Real Arcane::Timer::m_activation_time
private

Time spent during the last activation.

Definition at line 274 of file Timer.h.

Referenced by lastActivationTime(), reset(), start(), stop(), and Timer().

◆ m_is_activated

bool Arcane::Timer::m_is_activated
private

true if the timer is active

Definition at line 273 of file Timer.h.

Referenced by isActivated(), reset(), start(), stop(), and Timer().

◆ m_name

String Arcane::Timer::m_name
private

Timer name.

Definition at line 276 of file Timer.h.

Referenced by name(), and Timer().

◆ m_nb_activated

Integer Arcane::Timer::m_nb_activated
private

Number of times the timer has been activated.

Definition at line 272 of file Timer.h.

Referenced by nbActivated(), start(), and Timer().

◆ m_start_time

Real Arcane::Timer::m_start_time
private

Time of the start of the last activation.

Definition at line 277 of file Timer.h.

Referenced by _setStartTime(), _startTime(), and Timer().

◆ m_timer_mng

ITimerMng* Arcane::Timer::m_timer_mng
private

Timer manager.

Definition at line 270 of file Timer.h.

Referenced by start(), stop(), Timer(), and timerMng().

◆ m_total_time

Real Arcane::Timer::m_total_time
private

Total time spent in the timer.

Definition at line 275 of file Timer.h.

Referenced by reset(), stop(), Timer(), and totalTime().

◆ m_type

eTimerType Arcane::Timer::m_type
private

Timer type.

Definition at line 271 of file Timer.h.

Referenced by Timer(), and type().


The documentation for this class was generated from the following files: