IntervalTimerCommon.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * IntervalTimerCommon.cpp:
  3. *
  4. * Contains the common functions for interval timer. This set of functions makes no assumption on
  5. * the format of the RawTime objects and thus it operates through functions that abstract that
  6. * implementation away, or it is working on the raw values, as raw values.
  7. *
  8. * *Note:* If the RawTime object is using U32 upper to store seconds and U32 lower to store nano
  9. * seconds, then X86/IntervalTimer.cpp can be used, and the implementer need only fill in the
  10. * getRawTime function for the specific OS.
  11. */
  12. #include <Os/IntervalTimer.hpp>
  13. #include <cstring>
  14. namespace Os {
  15. IntervalTimer::IntervalTimer() {
  16. memset(&this->m_startTime,0,sizeof(this->m_startTime));
  17. memset(&this->m_stopTime,0,sizeof(this->m_stopTime));
  18. }
  19. IntervalTimer::~IntervalTimer() {}
  20. void IntervalTimer::start() {
  21. getRawTime(this->m_startTime);
  22. }
  23. void IntervalTimer::stop() {
  24. getRawTime(this->m_stopTime);
  25. }
  26. U32 IntervalTimer::getDiffUsec() {
  27. return getDiffUsec(this->m_stopTime, this->m_startTime);
  28. }
  29. }