timer.h 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2013 Dolphin Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #ifndef _TIMER_H_
  5. #define _TIMER_H_
  6. #include "common.h"
  7. #include <string>
  8. namespace Common
  9. {
  10. class Timer
  11. {
  12. public:
  13. Timer();
  14. void Start();
  15. void Stop();
  16. void Update();
  17. // The time difference is always returned in milliseconds, regardless of alternative internal representation
  18. u64 GetTimeDifference();
  19. void AddTimeDifference();
  20. static void IncreaseResolution();
  21. static void RestoreResolution();
  22. static u64 GetTimeSinceJan1970();
  23. static u64 GetLocalTimeSinceJan1970();
  24. static double GetDoubleTime();
  25. static std::string GetTimeFormatted();
  26. std::string GetTimeElapsedFormatted() const;
  27. u64 GetTimeElapsed();
  28. static u32 GetTimeMs();
  29. private:
  30. u64 m_LastTime;
  31. u64 m_StartTime;
  32. bool m_Running;
  33. };
  34. } // Namespace Common
  35. #endif // _TIMER_H_