NLMISC::CSimpleClock Class Reference

#include <hierarchical_timer.h>


Detailed Description

A simple clock to measure ticks.
Warning:
On intel platform, processor cycles are counted, on other platforms, CTime::getPerformanceTime is used instead.
See also:
CStopWatch
Author:
Nicolas Vizerie

Nevrax France

Date:
2002

Definition at line 96 of file hierarchical_timer.h.

Public Member Functions

 CSimpleClock ()
uint64 getNumTicks () const
void start ()
void stop ()

Static Public Member Functions

uint64 getStartStopNumTicks ()
void init ()

Private Attributes

uint64 _NumTicks
uint64 _StartTick

Static Private Attributes

bool _InitDone = false
uint64 _StartStopNumTicks = 0


Constructor & Destructor Documentation

NLMISC::CSimpleClock::CSimpleClock  )  [inline]
 

Definition at line 99 of file hierarchical_timer.h.

References _NumTicks.

00099                        : _NumTicks(0)
00100         {
00101 #               ifdef NL_DEBUG
00102                         _Started = false;
00103 #               endif
00104         }


Member Function Documentation

uint64 NLMISC::CSimpleClock::getNumTicks  )  const [inline]
 

Definition at line 133 of file hierarchical_timer.h.

References _NumTicks, nlassert, and uint64.

Referenced by NLMISC::CHTimer::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), NLMISC::CHTimer::displaySummary(), NLMISC::CHTimer::doAfter(), NLMISC::CHTimer::doBefore(), init(), and NL3D::CMiniTimer::~CMiniTimer().

00134         {
00135                 #ifdef NL_DEBUG
00136                         nlassert(!_Started);
00137                 #endif
00138                 nlassert(_NumTicks != 0);
00139                 return _NumTicks;
00140         }       

uint64 NLMISC::CSimpleClock::getStartStopNumTicks  )  [inline, static]
 

Get the number of ticks needed to perform start(). Should have called init() before calling this.

Definition at line 146 of file hierarchical_timer.h.

References _StartStopNumTicks, and uint64.

00147         {               
00148                 return _StartStopNumTicks; 
00149         }       

void NLMISC::CSimpleClock::init  )  [static]
 

Definition at line 67 of file hierarchical_timer.cpp.

References _InitDone, _StartStopNumTicks, getNumTicks(), start(), stop(), and uint.

00068 {       
00069         if (_InitDone) return;
00070         const uint numSamples = 10000;
00071 
00072         CSimpleClock observedClock;
00073         CSimpleClock measuringClock;
00074         
00075         measuringClock.start();
00076         for(uint l = 0; l < numSamples; ++l)
00077         {               
00078                 observedClock.start();
00079                 observedClock.stop();
00080         }
00081         measuringClock.stop();
00082 
00083         _StartStopNumTicks = (measuringClock.getNumTicks() >> 1) / numSamples;  
00084         _InitDone = true;
00085 }

void NLMISC::CSimpleClock::start  )  [inline]
 

Definition at line 106 of file hierarchical_timer.h.

References _StartTick, and nlassert.

Referenced by NL3D::CMiniTimer::CMiniTimer(), NLMISC::CHTimer::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), NLMISC::CHTimer::displaySummary(), NLMISC::CHTimer::doAfter(), NLMISC::CHTimer::doBefore(), and init().

00107         {
00108 #               ifdef  NL_DEBUG
00109                         nlassert(!_Started);
00110                         _Started = true;
00111 #               endif
00112 #               ifdef NL_CPU_INTEL
00113                 _StartTick = rdtsc();
00114 #               else
00115                 _StartTick = CTime::getPerformanceTime();
00116 #               endif
00117         }

void NLMISC::CSimpleClock::stop void   )  [inline]
 

Definition at line 119 of file hierarchical_timer.h.

References _NumTicks, _StartTick, and nlassert.

Referenced by NLMISC::CHTimer::display(), NLMISC::CHTimer::displayByExecutionPath(), NLMISC::CHTimer::displayHierarchical(), NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(), NLMISC::CHTimer::displaySummary(), NLMISC::CHTimer::doAfter(), NLMISC::CHTimer::doBefore(), init(), and NL3D::CMiniTimer::~CMiniTimer().

00120         {
00121 #               ifdef  NL_DEBUG
00122                         nlassert(_Started);
00123                         _Started = false;
00124 #               endif
00125 #               ifdef NL_CPU_INTEL
00126                 _NumTicks = rdtsc() - _StartTick;
00127 #               else
00128                 _NumTicks = CTime::getPerformanceTime() - _StartTick;
00129 #               endif
00130                 
00131         }       


Field Documentation

bool NLMISC::CSimpleClock::_InitDone = false [static, private]
 

Definition at line 43 of file hierarchical_timer.cpp.

Referenced by init().

uint64 NLMISC::CSimpleClock::_NumTicks [private]
 

Definition at line 152 of file hierarchical_timer.h.

Referenced by CSimpleClock(), getNumTicks(), and stop().

uint64 NLMISC::CSimpleClock::_StartStopNumTicks = 0 [static, private]
 

Definition at line 44 of file hierarchical_timer.cpp.

Referenced by getStartStopNumTicks(), and init().

uint64 NLMISC::CSimpleClock::_StartTick [private]
 

Definition at line 151 of file hierarchical_timer.h.

Referenced by start(), and stop().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:33:21 2004 for NeL by doxygen 1.3.6