12#ifndef ARCANE_UTILS_TRACETIMER_H
13#define ARCANE_UTILS_TRACETIMER_H
23#define DAY_TRACE_TIMER
27#if defined(MPI_TRACE_TIMER)
28#elif defined(DAY_TRACE_TIMER)
29#elif defined(CPU_TRACE_TIMER)
30#elif defined(SCPU_TRACE_TIMER)
32#error "TraceTimer type not defined"
47#if defined(MPI_TRACE_TIMER)
51 double systemTime()
const {
55 static const char * type() {
return "MPI Timer"; }
59#if defined(DAY_TRACE_TIMER)
63 return platform::getRealTime();
66 static const char * type() {
return "Day Timer"; }
70#if defined(CPU_TRACE_TIMER)
77 static const long _CLK_TCK = sysconf(_SC_CLK_TCK);
79 return static_cast<double>(tp.tms_utime)/_CLK_TCK;
82 static const char * type() {
return "Cpu Timer"; }
86#if defined(SCPU_TRACE_TIMER)
89class InnerTimer_SysCPU {
93 static const long _CLK_TCK = sysconf(_SC_CLK_TCK);
94 return static_cast<double>(times(&tp))/_CLK_TCK;
97 static const char * type() {
return "SysCpu Timer"; }
102template<
typename Model>
105 enum ClockState { init, stopped, running };
119 : state(init), t0(0), t1(0), total(0) {
133 t0 = this->systemTime();
139 if (state == running) {
140 t1 = this->systemTime();
144 t0 = this->systemTime();
149 assert(state == running);
151 t1 = this->systemTime();
163 assert(state != init);
164 if (state == running)
165 t1 = this->systemTime();
171 assert(state != init);
172 if (state == running)
173 return total + this->systemTime() - t0;
175 assert(state == stopped);
180#if defined(MPI_TRACE_TIMER)
181typedef TraceTimerT<InnerTimer_MPI> TraceTimer;
182#elif defined(DAY_TRACE_TIMER)
183typedef TraceTimerT<InnerTimer_DAY> TraceTimer;
184#elif defined(CPU_TRACE_TIMER)
185typedef TraceTimerT<InnerTimer_CPU> TraceTimer;
186#elif defined(SCPU_TRACE_TIMER)
187typedef TraceTimerT<InnerTimer_SysCPU> TraceTimer;
double getCumulTime()
get total time
double getTime()
get partial time
void start()
start the timer or restart without cumulate
void restart()
start or restart the timer and cumuluate
TraceTimerT(const bool _start=true)
New timer.
ClockState getState() const
return state of timer