Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Nektar::Timer Class Reference

#include <Timer.h>

Public Types

typedef timespec CounterType

Public Member Functions

 Timer ()
 ~Timer ()
void Start ()
void Stop ()
CounterType Elapsed ()
NekDouble TimePerTest (unsigned int n)
 Returns amount of seconds per iteration in a test with n iterations.

Private Member Functions

 Timer (const Timer &rhs)
Timeroperator= (const Timer &rhs)

Private Attributes

CounterType m_start
CounterType m_end
CounterType m_resolution

Detailed Description

Definition at line 52 of file Timer.h.

Member Typedef Documentation

typedef timespec Nektar::Timer::CounterType

Definition at line 60 of file Timer.h.

Constructor & Destructor Documentation

Nektar::Timer::Timer ( )

Definition at line 40 of file Timer.cpp.

:
m_end(),
{
}
Nektar::Timer::~Timer ( )

Definition at line 47 of file Timer.cpp.

{
}
Nektar::Timer::Timer ( const Timer rhs)
private

Member Function Documentation

Timer::CounterType Nektar::Timer::Elapsed ( )

Definition at line 73 of file Timer.cpp.

References m_end, and m_start.

Referenced by TimePerTest().

{
#ifdef _WIN32
CounterType result;
result.QuadPart = m_end.QuadPart - m_start.QuadPart;
return result;
#elif defined(__APPLE__)
CounterType result = m_end;
if( result.tv_usec < m_start.tv_usec)
{
result.tv_sec -= 1;
result.tv_usec += 1000000;
}
result.tv_sec -= m_start.tv_sec;
result.tv_usec -= m_start.tv_usec;
return result;
#else
CounterType result = m_end;
if( result.tv_nsec < m_start.tv_nsec)
{
result.tv_sec -= 1;
result.tv_nsec += 1000000000;
}
result.tv_sec -= m_start.tv_sec;
result.tv_nsec -= m_start.tv_nsec;
return result;
#endif
}
Timer& Nektar::Timer::operator= ( const Timer rhs)
private
void Nektar::Timer::Start ( )

Definition at line 51 of file Timer.cpp.

References m_start.

Referenced by Nektar::LibUtilities::AnalyticExpressionEvaluator::Evaluate(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoint(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoints(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::CoupledLinearNS::SolveSteadyNavierStokes(), Nektar::SolverUtils::UnsteadySystem::v_DoSolve(), Nektar::PulseWaveSystem::v_DoSolve(), and Nektar::CoupledLinearNS::v_DoSolve().

{
#ifdef _WIN32
QueryPerformanceCounter(&m_start);
#elif defined(__APPLE__)
gettimeofday(&m_start, 0);
#else
clock_gettime(CLOCK_REALTIME, &m_start);
#endif
}
void Nektar::Timer::Stop ( )

Definition at line 62 of file Timer.cpp.

References m_end.

Referenced by Nektar::LibUtilities::AnalyticExpressionEvaluator::Evaluate(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoint(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoints(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::CoupledLinearNS::SolveSteadyNavierStokes(), Nektar::SolverUtils::UnsteadySystem::v_DoSolve(), Nektar::PulseWaveSystem::v_DoSolve(), and Nektar::CoupledLinearNS::v_DoSolve().

{
#ifdef _WIN32
QueryPerformanceCounter(&m_end);
#elif defined(__APPLE__)
gettimeofday(&m_end, 0);
#else
clock_gettime(CLOCK_REALTIME, &m_end);
#endif
}
NekDouble Nektar::Timer::TimePerTest ( unsigned int  n)

Returns amount of seconds per iteration in a test with n iterations.

Definition at line 108 of file Timer.cpp.

References Elapsed().

Referenced by Nektar::LibUtilities::AnalyticExpressionEvaluator::Evaluate(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoint(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoints(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::CoupledLinearNS::SolveSteadyNavierStokes(), Nektar::SolverUtils::UnsteadySystem::v_DoSolve(), Nektar::PulseWaveSystem::v_DoSolve(), and Nektar::CoupledLinearNS::v_DoSolve().

{
#ifdef _WIN32
CounterType frequency;
QueryPerformanceFrequency(&frequency);
return Elapsed().QuadPart/static_cast<NekDouble>(n) * 1.0/frequency.QuadPart;
#elif defined(__APPLE__)
CounterType elapsed = Elapsed();
NekDouble result = elapsed.tv_sec/static_cast<NekDouble>(n) +
( elapsed.tv_usec/static_cast<NekDouble>(n) * 1.0e-6);
return result;
#else
CounterType elapsed = Elapsed();
NekDouble result = elapsed.tv_sec/static_cast<NekDouble>(n) +
( elapsed.tv_nsec/static_cast<NekDouble>(n) * 1.0e-9);
return result;
#endif
}

Member Data Documentation

CounterType Nektar::Timer::m_end
private

Definition at line 80 of file Timer.h.

Referenced by Elapsed(), and Stop().

CounterType Nektar::Timer::m_resolution
private

Definition at line 81 of file Timer.h.

CounterType Nektar::Timer::m_start
private

Definition at line 79 of file Timer.h.

Referenced by Elapsed(), and Start().