HighRezTimer.h 819 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. {
  9. /// @addtogroup util_time
  10. /// @{
  11. /// High resolution timer. All time in seconds
  12. class HighRezTimer
  13. {
  14. public:
  15. /// Start the timer
  16. void start();
  17. /// Stop the timer
  18. void stop();
  19. /// Get the time elapsed between start and stop (if its stopped) or between start and the current time.
  20. Second getElapsedTime() const;
  21. /// Get the current date's seconds
  22. static Second getCurrentTime();
  23. /// Micro sleep. The resolution is in nanoseconds.
  24. static void sleep(Second seconds);
  25. private:
  26. Second m_startTime = 0.0;
  27. Second m_stopTime = 0.0;
  28. };
  29. /// @}
  30. } // end namespace anki