Listing 1: clock.hpp.
// clock.hpp Begin #ifdef __PALMOS #include <SystemMgr.h> #include <TimeMgr.h> #define CLOCKS_PER_SEC ((clock_t)SysTicksPerSecond()) typedef long clock_t; #elif defined( __WINDOWS ) #include <windows.h> #define CLOCKS_PER_SEC 1000 typedef long clock_t; #else #include <time.h> #endif class cClock { public: cClock( clock_t ClocksPerSec = CLOCKS_PER_SEC ); cClock( clock_t CalPeriod, clock_t CalError, clock_t ClocksPerSec = CLOCKS_PER_SEC ); ~cClock() {}; clock_t StartClock(); clock_t GetClock(); clock_t GetCalClock(); clock_t GetClocksPerSec(); static void SetCalibration( clock_t CalPeriod, clock_t CalCorrection ); static void CalcCalibration( clock_t ActualTime, clock_t MeasuredTime, clock_t Correction ); private: static clock_t _mClockStart; static clock_t _mNumClockCalls; static clock_t _mDesClockRes; static clock_t _mDesClocksPerSec; static clock_t _mNatClockRes; static clock_t _mCalPeriod; static clock_t _mCalCorrection; static void InitClock(); static inline clock_t LoopClock( clock_t Clock1, clock_t *NumCalls ); static void SetClockRes( clock_t ClocksPerSec ); static clock_t RoundToRes( clock_t Clock ); }; // clock.hpp End