metaforce/Runtime/CStopwatch.hpp

32 lines
739 B
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2017-11-19 07:10:54 +00:00
#include "Runtime/GCNTypes.hpp"
#include <cmath>
2017-11-19 07:10:54 +00:00
#include <chrono>
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
class CStopwatch {
private:
static CStopwatch mGlobalTimer;
2018-12-08 05:30:43 +00:00
using Time = std::chrono::steady_clock;
using MicroSeconds = std::chrono::microseconds;
using MilliSeconds = std::chrono::milliseconds;
using FloatSeconds = std::chrono::duration<float>;
Time::time_point m_startTime;
2017-11-19 07:10:54 +00:00
public:
static void InitGlobalTimer();
static CStopwatch& GetGlobalTimerObj() { return mGlobalTimer; }
static float GetGlobalTime() { return mGlobalTimer.GetElapsedTime(); }
void Reset();
void Wait(float wait);
float GetElapsedTime() const;
u16 GetElapsedMicros() const;
u64 GetCurMicros() const;
2017-11-19 07:10:54 +00:00
};
2021-04-10 08:42:06 +00:00
} // namespace metaforce