HighRezTimer.h 819 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Util/StdTypes.h>
  7. namespace anki {
  8. /// @addtogroup util_time
  9. /// @{
  10. /// High resolution timer. All time in seconds
  11. class HighRezTimer
  12. {
  13. public:
  14. /// Start the timer
  15. void start();
  16. /// Stop the timer
  17. void stop();
  18. /// Get the time elapsed between start and stop (if its stopped) or between start and the current time.
  19. Second getElapsedTime() const;
  20. /// Get the current date's seconds
  21. static Second getCurrentTime();
  22. /// Micro sleep. The resolution is in nanoseconds.
  23. static void sleep(Second seconds);
  24. private:
  25. Second m_startTime = 0.0;
  26. Second m_stopTime = 0.0;
  27. };
  28. /// @}
  29. } // end namespace anki