BsTimer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPrerequisitesUtil.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup General
  8. * @{
  9. */
  10. /**
  11. * Timer class used for querying high precision timers.
  12. *
  13. * @note Not thread safe.
  14. */
  15. class BS_UTILITY_EXPORT Timer
  16. {
  17. public:
  18. /** Construct the timer and start timing. */
  19. Timer();
  20. /** Reset the timer to zero. */
  21. void reset();
  22. /** Returns time in milliseconds since timer was initialized or last reset. */
  23. UINT64 getMilliseconds() const;
  24. /** Returns time in microseconds since timer was initialized or last reset. */
  25. UINT64 getMicroseconds() const;
  26. /**
  27. * Returns the time at which the timer was initialized, in milliseconds.
  28. *
  29. * @return Time in milliseconds.
  30. */
  31. UINT64 getStartMs() const;
  32. private:
  33. std::chrono::high_resolution_clock mHRClock;
  34. std::chrono::steady_clock::time_point mStartTime;
  35. };
  36. /** @} */
  37. }