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)
53 double systemTime()
const
60 static const char* type() {
return "MPI Timer"; }
64#if defined(DAY_TRACE_TIMER)
76 static const char* type() {
return "Day Timer"; }
80#if defined(CPU_TRACE_TIMER)
90 static const long _CLK_TCK = sysconf(_SC_CLK_TCK);
92 return static_cast<double>(tp.tms_utime) / _CLK_TCK;
97 static const char* type() {
return "Cpu Timer"; }
101#if defined(SCPU_TRACE_TIMER)
103#include <sys/times.h>
104class InnerTimer_SysCPU
111 static const long _CLK_TCK = sysconf(_SC_CLK_TCK);
112 return static_cast<double>(times(&tp)) / _CLK_TCK;
117 static const char* type() {
return "SysCpu Timer"; }
121template <
typename Model>
170 t0 = this->systemTime();
177 if (state == running) {
178 t1 = this->systemTime();
182 t0 = this->systemTime();
188 assert(state == running);
190 t1 = this->systemTime();
204 assert(state != init);
205 if (state == running)
206 t1 = this->systemTime();
213 assert(state != init);
214 if (state == running)
215 return total + this->systemTime() - t0;
217 assert(state == stopped);
222#if defined(MPI_TRACE_TIMER)
223typedef TraceTimerT<InnerTimer_MPI> TraceTimer;
224#elif defined(DAY_TRACE_TIMER)
225typedef TraceTimerT<InnerTimer_DAY> TraceTimer;
226#elif defined(CPU_TRACE_TIMER)
227typedef TraceTimerT<InnerTimer_CPU> TraceTimer;
228#elif defined(SCPU_TRACE_TIMER)
229typedef 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
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --