b3Clock.h 987 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef B3_CLOCK_H
  2. #define B3_CLOCK_H
  3. ///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
  4. class b3Clock
  5. {
  6. public:
  7. b3Clock();
  8. b3Clock(const b3Clock& other);
  9. b3Clock& operator=(const b3Clock& other);
  10. ~b3Clock();
  11. /// Resets the initial reference time.
  12. void reset();
  13. /// Returns the time in ms since the last call to reset or since
  14. /// the b3Clock was created.
  15. unsigned long int getTimeMilliseconds();
  16. /// Returns the time in us since the last call to reset or since
  17. /// the Clock was created.
  18. unsigned long long int getTimeMicroseconds();
  19. /// Returns the time in seconds since the last call to reset or since
  20. /// the Clock was created.
  21. double getTimeInSeconds();
  22. ///Sleep for 'microSeconds', to yield to other threads and not waste 100% CPU cycles.
  23. ///Note that some operating systems may sleep a longer time.
  24. static void usleep(int microSeconds);
  25. private:
  26. struct b3ClockData* m_data;
  27. };
  28. #endif //B3_CLOCK_H