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

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

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

◆ 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 name(), and type().

◆ ~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.

◆ _startTime()

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

Definition at line 266 of file Timer.h.

◆ isActivated()

bool Arcane::Timer::isActivated ( ) const
inline

Returns the activation status of the timer.

Definition at line 234 of file Timer.h.

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

Referenced by Arcane::Materials::ItemMaterialVariableScalar< DataType >::synchronize().

◆ name()

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

Returns the name of the timer.

Definition at line 237 of file Timer.h.

Referenced by Timer(), and Timer().

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

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

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

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

◆ timerMng()

ITimerMng * Arcane::Timer::timerMng ( ) const
inline

Manager associated with this timer.

Definition at line 255 of file Timer.h.

Referenced by Timer().

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

◆ type()

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

Returns the type of time used.

Definition at line 249 of file Timer.h.

Referenced by Timer(), and Timer().


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