Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728
  1. /*!
  2. * \file src/utils/time.cpp
  3. * \brief Time handling utilities
  4. *
  5. * \author xythobuz
  6. */
  7. #include <chrono>
  8. #include "global.h"
  9. #include "utils/time.h"
  10. static unsigned long systemTimerStart = 0;
  11. unsigned long systemTimerGet() {
  12. auto tp = std::chrono::steady_clock::now();
  13. auto dtn = tp.time_since_epoch();
  14. return (dtn.count() * 1000 * std::chrono::steady_clock::period::num
  15. / std::chrono::steady_clock::period::den) - systemTimerStart;
  16. }
  17. void systemTimerReset() {
  18. auto tp = std::chrono::steady_clock::now();
  19. auto dtn = tp.time_since_epoch();
  20. systemTimerStart = dtn.count() * 1000 * std::chrono::steady_clock::period::num
  21. / std::chrono::steady_clock::period::den;
  22. }