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. More...
 

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.

40  :
41  m_start(),
42  m_end(),
43  m_resolution()
44  {
45  }
CounterType m_start
Definition: Timer.h:79
CounterType m_end
Definition: Timer.h:80
CounterType m_resolution
Definition: Timer.h:81
Nektar::Timer::~Timer ( )

Definition at line 47 of file Timer.cpp.

48  {
49  }
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().

74  {
75  #ifdef _WIN32
76  CounterType result;
77  result.QuadPart = m_end.QuadPart - m_start.QuadPart;
78  return result;
79  #elif defined(__APPLE__)
80  CounterType result = m_end;
81 
82  if( result.tv_usec < m_start.tv_usec)
83  {
84  result.tv_sec -= 1;
85  result.tv_usec += 1000000;
86  }
87 
88  result.tv_sec -= m_start.tv_sec;
89  result.tv_usec -= m_start.tv_usec;
90 
91  return result;
92  #else
93  CounterType result = m_end;
94 
95  if( result.tv_nsec < m_start.tv_nsec)
96  {
97  result.tv_sec -= 1;
98  result.tv_nsec += 1000000000;
99  }
100 
101  result.tv_sec -= m_start.tv_sec;
102  result.tv_nsec -= m_start.tv_nsec;
103 
104  return result;
105  #endif
106  }
CounterType m_start
Definition: Timer.h:79
CounterType m_end
Definition: Timer.h:80
timespec CounterType
Definition: Timer.h:60
Timer& Nektar::Timer::operator= ( const Timer rhs)
private
void Nektar::Timer::Start ( )
void Nektar::Timer::Stop ( )
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::SolverUtils::DriverSteadyState::ConvergenceHistory(), Nektar::LibUtilities::AnalyticExpressionEvaluator::Evaluate(), Nektar::LibUtilities::AnalyticExpressionEvaluator::EvaluateAtPoint(), main(), Nektar::Utilities::InputXml::Process(), Nektar::CoupledLinearNS::SetUpCoupledMatrix(), Nektar::CoupledLinearNS::SolveSteadyNavierStokes(), Nektar::SolverUtils::UnsteadySystem::v_DoSolve(), Nektar::PulseWaveSystem::v_DoSolve(), and Nektar::CoupledLinearNS::v_DoSolve().

109  {
110  #ifdef _WIN32
111  CounterType frequency;
112  QueryPerformanceFrequency(&frequency);
113  return Elapsed().QuadPart/static_cast<NekDouble>(n) * 1.0/frequency.QuadPart;
114  #elif defined(__APPLE__)
115  CounterType elapsed = Elapsed();
116  NekDouble result = elapsed.tv_sec/static_cast<NekDouble>(n) +
117  ( elapsed.tv_usec/static_cast<NekDouble>(n) * 1.0e-6);
118  return result;
119  #else
120  CounterType elapsed = Elapsed();
121  NekDouble result = elapsed.tv_sec/static_cast<NekDouble>(n) +
122  ( elapsed.tv_nsec/static_cast<NekDouble>(n) * 1.0e-9);
123  return result;
124  #endif
125  }
timespec CounterType
Definition: Timer.h:60
double NekDouble
CounterType Elapsed()
Definition: Timer.cpp:73

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().