HighRezTimer.cpp 670 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2009-present, 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. void HighRezTimer::start()
  9. {
  10. m_startTime = getCurrentTime();
  11. m_stopTime = 0.0;
  12. }
  13. void HighRezTimer::stop()
  14. {
  15. ANKI_ASSERT(m_startTime != 0.0);
  16. ANKI_ASSERT(m_stopTime == 0.0);
  17. m_stopTime = getCurrentTime();
  18. }
  19. Second HighRezTimer::getElapsedTime() const
  20. {
  21. if(m_stopTime == 0.0)
  22. {
  23. return getCurrentTime() - m_startTime;
  24. }
  25. else
  26. {
  27. return m_stopTime - m_startTime;
  28. }
  29. }
  30. } // end namespace anki