BsTimer.h 1.2 KB

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