13#include "SolverStater.h"
17#define ARCANE_TIMER_USE_CLOCK
23#include <arccore/base/FatalErrorException.h>
24#include <arccore/base/TraceInfo.h>
32using namespace Arccore;
35#ifdef ARCANE_TIMER_USE_CLOCK
36static clock_t current_clock_value = 0;
42Real BaseSolverStater::_getVirtualTime()
45#ifdef ARCANE_TIMER_USE_CLOCK
46 clock_t cv = ::clock();
47 Real diffv =
static_cast<Real
>(cv - current_clock_value);
48 return diffv / CLOCKS_PER_SEC;
50 struct itimerval time_val;
51 int r = ::getitimer(ITIMER_VIRTUAL, &time_val);
53 _errorInTimer(
"getitimer()", r);
54 Real v =
static_cast<Real
>(time_val.it_value.tv_sec) * 1. +
static_cast<Real
>(time_val.it_value.tv_usec) * 1e-6;
55 return (5000000. - v);
61Real BaseSolverStater::_getRealTime()
67 Real hour = t.wHour * 3600.0;
68 Real minute = t.wMinute * 60.0;
69 Real second = t.wSecond;
70 Real milli_second = t.wMilliseconds * 1e-3;
71 return (hour + minute + second + milli_second);
74 int r = gettimeofday(&tp, 0);
76 _errorInTimer(
"gettimeofday()", r);
78 (
static_cast<Real
>(tp.tv_sec) * 1. +
static_cast<Real
>(tp.tv_usec) * 1.e-6);
85void BaseSolverStater::_errorInTimer(
const String& msg,
int retcode)
87 throw FatalErrorException(
88 A_FUNCINFO, String::format(
"{0} return code: {1} errno: {2}", msg, retcode, errno));
93void BaseSolverStater::_startTimer()
95 ALIEN_ASSERT((m_state == eNone), (
"Unexpected SolverStater state %d", m_state));
102void BaseSolverStater::_stopTimer()
104 ALIEN_ASSERT((m_state != eNone), (
"Unexpected SolverStater state %d", m_state));
Real m_cpu_time
'cpu' time for the lastest start or stop
Real m_real_time
'wall clock' time for the lastest start or stop
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --