timer.h
1 // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <chrono> 8 #include <string> 9 #include "common/common_types.h" 10 11 namespace Common { 12 class Timer { 13 public: 14 Timer(); 15 16 void Start(); 17 void Stop(); 18 void Update(); 19 20 // The time difference is always returned in milliseconds, regardless of alternative internal 21 // representation 22 [[nodiscard]] std::chrono::milliseconds GetTimeDifference(); 23 void AddTimeDifference(); 24 25 [[nodiscard]] static std::chrono::seconds GetTimeSinceJan1970(); 26 [[nodiscard]] static std::chrono::seconds GetLocalTimeSinceJan1970(); 27 28 [[nodiscard]] static std::string GetTimeFormatted(); 29 [[nodiscard]] std::string GetTimeElapsedFormatted() const; 30 [[nodiscard]] std::chrono::milliseconds GetTimeElapsed(); 31 32 [[nodiscard]] static std::chrono::milliseconds GetTimeMs(); 33 34 private: 35 std::chrono::milliseconds m_LastTime; 36 std::chrono::milliseconds m_StartTime; 37 bool m_Running; 38 }; 39 40 } // Namespace Common