HighRezTimer.cpp 667 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #include <AnKi/Util/HighRezTimer.h>
  6. #include <AnKi/Util/Assert.h>
  7. namespace anki
  8. {
  9. void HighRezTimer::start()
  10. {
  11. m_startTime = getCurrentTime();
  12. m_stopTime = 0.0;
  13. }
  14. void HighRezTimer::stop()
  15. {
  16. ANKI_ASSERT(m_startTime != 0.0);
  17. ANKI_ASSERT(m_stopTime == 0.0);
  18. m_stopTime = getCurrentTime();
  19. }
  20. Second HighRezTimer::getElapsedTime() const
  21. {
  22. if(m_stopTime == 0.0)
  23. {
  24. return getCurrentTime() - m_startTime;
  25. }
  26. else
  27. {
  28. return m_stopTime - m_startTime;
  29. }
  30. }
  31. } // end namespace anki