| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2008 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-17 23:09:55 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-15 11:46:09 +00:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-21 19:55:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | namespace Common | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | class Timer | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   Timer(); | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   void Start(); | 
					
						
							|  |  |  |   void Stop(); | 
					
						
							|  |  |  |   void Update(); | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   // The time difference is always returned in milliseconds, regardless of alternative internal
 | 
					
						
							|  |  |  |   // representation
 | 
					
						
							|  |  |  |   u64 GetTimeDifference(); | 
					
						
							|  |  |  |   void AddTimeDifference(); | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   static void IncreaseResolution(); | 
					
						
							|  |  |  |   static void RestoreResolution(); | 
					
						
							|  |  |  |   static u64 GetTimeSinceJan1970(); | 
					
						
							|  |  |  |   static u64 GetLocalTimeSinceJan1970(); | 
					
						
							|  |  |  |   // Returns a timestamp with decimals for precise time comparisons
 | 
					
						
							|  |  |  |   static double GetDoubleTime(); | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   static std::string GetTimeFormatted(); | 
					
						
							|  |  |  |   // Formats a timestamp from GetDoubleTime() into a date and time string
 | 
					
						
							|  |  |  |   static std::string GetDateTimeFormatted(double time); | 
					
						
							|  |  |  |   std::string GetTimeElapsedFormatted() const; | 
					
						
							|  |  |  |   u64 GetTimeElapsed(); | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   static u32 GetTimeMs(); | 
					
						
							|  |  |  |   static u64 GetTimeUs(); | 
					
						
							| 
									
										
										
										
											2010-01-21 19:55:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   // Arbitrarily chosen value (38 years) that is subtracted in GetDoubleTime()
 | 
					
						
							|  |  |  |   // to increase sub-second precision of the resulting double timestamp
 | 
					
						
							|  |  |  |   static const int DOUBLE_TIME_OFFSET = (38 * 365 * 24 * 60 * 60); | 
					
						
							| 
									
										
										
										
											2015-07-12 01:49:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-21 19:55:01 +00:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   u64 m_LastTime; | 
					
						
							|  |  |  |   u64 m_StartTime; | 
					
						
							|  |  |  |   bool m_Running; | 
					
						
							| 
									
										
										
										
											2008-12-08 04:46:09 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-02-22 12:43:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  | }  // Namespace Common
 |