BsTimer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. ~Timer();
  21. /** Reset the timer to zero. */
  22. void reset();
  23. /** Returns time in milliseconds since timer was initialized or last reset. */
  24. unsigned long getMilliseconds();
  25. /** Returns time in microseconds since timer was initialized or last reset. */
  26. unsigned long getMicroseconds();
  27. /** Returns time in milliseconds since timer was initialized or last reset. Only CPU timer measured. */
  28. unsigned long getMillisecondsCPU();
  29. /** Returns time in microseconds since timer was initialized or last reset. Only CPU timer measured. */
  30. unsigned long getMicrosecondsCPU();
  31. /**
  32. * Returns the time at which the timer was initialized, in milliseconds.
  33. *
  34. * @return Time in milliseconds.
  35. */
  36. unsigned long getStartMs() const;
  37. private:
  38. struct Data;
  39. Data* m;
  40. };
  41. /** @} */
  42. }