Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
TimerMng.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* TimerMng.cc (C) 2000-2022 */
9/* */
10/* Implementation of a timer manager. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/impl/TimerMng.h"
15
16#include "arcane/utils/Iterator.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/TraceInfo.h"
20#include "arcane/utils/PlatformUtils.h"
21
22#include "arcane/core/ArcaneException.h"
23#include "arcane/core/Timer.h"
24#include "arcane/core/ISubDomain.h"
25#include "arcane/core/IMainFactory.h"
26
27#include <algorithm>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
39TimerMng(ITraceMng* trace)
40: TraceAccessor(trace)
41{
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
51beginTimer(Timer* timer)
52{
53 Real tvalue = _getRealTime();
54 timer->_setStartTime(tvalue);
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
61getTime(Timer* timer)
62{
63 Real tvalue = _getRealTime();
64 Real active_value = tvalue - timer->_startTime();
65 return active_value;
66}
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
72endTimer(Timer* timer)
73{
74 Real tvalue = _getRealTime();
75 Real active_value = tvalue - timer->_startTime();
76 return active_value;
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
83hasTimer(Timer* timer)
84{
85 return timer->timerMng() == this && timer->isActivated();
86}
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103void TimerMng::
104_errorInTimer(const String& msg, int retcode)
105{
106 warning() << "In TimerMng::_errorInTimer() "
107 << msg << " return code: " << retcode << " errno: " << errno;
108}
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
112
113} // End namespace Arcane
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
bool hasTimer(Timer *timer) override
Indicates if the timer timer is registered.
Definition TimerMng.cc:83
TimerMng(ITraceMng *msg)
Constructs a timer linked to the manager mng.
Definition TimerMng.cc:39
virtual Real _getRealTime()
Returns the real time.
Definition TimerMng.cc:92
Real getTime(Timer *timer) override
Time elapsed since the last call to beginTimer().
Definition TimerMng.cc:61
void beginTimer(Timer *timer) override
Attaches the timer timer to this manager.
Definition TimerMng.cc:51
Real endTimer(Timer *timer) override
Releases the timer timer.
Definition TimerMng.cc:72
Management of a timer.
Definition Timer.h:63
void _setStartTime(Real t)
Definition Timer.h:264
Real _startTime() const
Definition Timer.h:266
ITimerMng * timerMng() const
Manager associated with this timer.
Definition Timer.h:255
bool isActivated() const
Returns the activation status of the timer.
Definition Timer.h:234
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage warning() const
Flow for a warning message.
Real getRealTime()
Real time used in seconds.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.