BsTimer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. namespace BansheeEngine
  4. {
  5. /** @addtogroup General
  6. * @{
  7. */
  8. /**
  9. * Timer class used for querying high precision timers.
  10. *
  11. * @note Not thread safe.
  12. */
  13. class BS_UTILITY_EXPORT Timer
  14. {
  15. public:
  16. /** Construct the timer and start timing. */
  17. Timer();
  18. ~Timer();
  19. /** Reset the timer to zero. */
  20. void reset();
  21. /** Returns time in milliseconds since timer was initialized or last reset. */
  22. unsigned long getMilliseconds();
  23. /** Returns time in microseconds since timer was initialized or last reset. */
  24. unsigned long getMicroseconds();
  25. /** Returns time in milliseconds since timer was initialized or last reset. Only CPU timer measured. */
  26. unsigned long getMillisecondsCPU();
  27. /** Returns time in microseconds since timer was initialized or last reset. Only CPU timer measured. */
  28. unsigned long getMicrosecondsCPU();
  29. /**
  30. * Returns the time at which the timer was initialized, in milliseconds.
  31. *
  32. * @return Time in milliseconds.
  33. */
  34. unsigned long getStartMs() const;
  35. private:
  36. struct Data;
  37. Data* m;
  38. };
  39. /** @} */
  40. }