Timer.inl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef SE_INCL_TIMER_INL
  2. #define SE_INCL_TIMER_INL
  3. #ifdef PRAGMA_ONCE
  4. #pragma once
  5. #endif
  6. /* Constructor from seconds. */
  7. inline CTimerValue::CTimerValue(double fSeconds)
  8. {
  9. tv_llValue = __int64(fSeconds*_pTimer->tm_llPerformanceCounterFrequency);
  10. }
  11. /* Clear timer value (set it to zero). */
  12. inline void CTimerValue::Clear(void)
  13. {
  14. tv_llValue = 0;
  15. }
  16. /* Addition. */
  17. inline CTimerValue &CTimerValue::operator+=(const CTimerValue &tvOther) {
  18. tv_llValue+=tvOther.tv_llValue;
  19. return *this;
  20. };
  21. inline CTimerValue CTimerValue::operator+(const CTimerValue &tvOther) const {
  22. return CTimerValue(*this)+=tvOther;
  23. };
  24. /* Substraction. */
  25. inline CTimerValue &CTimerValue::operator-=(const CTimerValue &tvOther) {
  26. tv_llValue-=tvOther.tv_llValue;
  27. return *this;
  28. };
  29. inline CTimerValue CTimerValue::operator-(const CTimerValue &tvOther) const {
  30. return CTimerValue(*this)-=tvOther;
  31. };
  32. /* Comparisons. */
  33. inline BOOL CTimerValue::operator<(const CTimerValue &tvOther) const {
  34. return tv_llValue<tvOther.tv_llValue;
  35. }
  36. inline BOOL CTimerValue::operator>(const CTimerValue &tvOther) const {
  37. return tv_llValue>tvOther.tv_llValue;
  38. }
  39. inline BOOL CTimerValue::operator<=(const CTimerValue &tvOther) const {
  40. return tv_llValue<=tvOther.tv_llValue;
  41. }
  42. inline BOOL CTimerValue::operator>=(const CTimerValue &tvOther) const {
  43. return tv_llValue>=tvOther.tv_llValue;
  44. }
  45. /* Get the timer value in seconds. - use for time spans only! */
  46. inline double CTimerValue::GetSeconds(void) {
  47. return ((double)tv_llValue)/_pTimer->tm_llPerformanceCounterFrequency;
  48. };
  49. /* Get the timer value in milliseconds as integral value. */
  50. inline __int64 CTimerValue::GetMilliseconds(void) {
  51. return tv_llValue/(_pTimer->tm_llPerformanceCounterFrequency/1000);
  52. };
  53. #endif /* include-once check. */