BsTimer.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 bs
  6. {
  7. /** @addtogroup General
  8. * @{
  9. */
  10. /** Timer class used for querying high precision timers. */
  11. class BS_UTILITY_EXPORT Timer
  12. {
  13. public:
  14. /** Construct the timer and start timing. */
  15. Timer();
  16. /** Reset the timer to zero. */
  17. void reset();
  18. /** Returns time in milliseconds since timer was initialized or last reset. */
  19. UINT64 getMilliseconds() const;
  20. /** Returns time in microseconds since timer was initialized or last reset. */
  21. UINT64 getMicroseconds() const;
  22. /**
  23. * Returns the time at which the timer was initialized, in milliseconds.
  24. *
  25. * @return Time in milliseconds.
  26. */
  27. UINT64 getStartMs() const;
  28. private:
  29. std::chrono::high_resolution_clock mHRClock;
  30. std::chrono::time_point<std::chrono::high_resolution_clock> mStartTime;
  31. };
  32. /** @} */
  33. }