HighRezTimer.h 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  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. /// The type that the timer manipulates the results
  16. using Scalar = F64;
  17. /// Start the timer
  18. void start();
  19. /// Stop the timer
  20. void stop();
  21. /// Get the time elapsed between start and stop (if its stopped) or
  22. /// between start and the current time
  23. Scalar getElapsedTime() const;
  24. /// Get the current date's seconds
  25. static Scalar getCurrentTime();
  26. /// Micro sleep.
  27. /// The resolution is in nanoseconds.
  28. static void sleep(Scalar seconds);
  29. private:
  30. Scalar m_startTime = 0.0;
  31. Scalar m_stopTime = 0.0;
  32. };
  33. /// @}
  34. } // end namespace anki