common/timer: use std::chrono, avoid platform-dependent code

* core/timer: use even more std::chrono

* common/timer: convert GetLocalTimeSinceJan1970
This commit is contained in:
zhupengfei 2018-07-21 17:09:15 +08:00
parent 78685065cf
commit 872e505cc6
No known key found for this signature in database
GPG key ID: 85B82A3E62174206
2 changed files with 33 additions and 80 deletions

View file

@ -4,6 +4,7 @@
#pragma once
#include <chrono>
#include <string>
#include "common/common_types.h"
@ -18,24 +19,22 @@ public:
// The time difference is always returned in milliseconds, regardless of alternative internal
// representation
u64 GetTimeDifference();
std::chrono::milliseconds GetTimeDifference();
void AddTimeDifference();
static void IncreaseResolution();
static void RestoreResolution();
static u64 GetTimeSinceJan1970();
static u64 GetLocalTimeSinceJan1970();
static std::chrono::seconds GetTimeSinceJan1970();
static std::chrono::seconds GetLocalTimeSinceJan1970();
static double GetDoubleTime();
static std::string GetTimeFormatted();
std::string GetTimeElapsedFormatted() const;
u64 GetTimeElapsed();
std::chrono::milliseconds GetTimeElapsed();
static u32 GetTimeMs();
static std::chrono::milliseconds GetTimeMs();
private:
u64 m_LastTime;
u64 m_StartTime;
std::chrono::milliseconds m_LastTime;
std::chrono::milliseconds m_StartTime;
bool m_Running;
};