metaforce/Runtime/CStopwatch.hpp

32 lines
739 B
C++
Raw Permalink Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2017-11-18 23:10:54 -08:00
#include "Runtime/GCNTypes.hpp"
#include <cmath>
2017-11-18 23:10:54 -08:00
#include <chrono>
2021-04-10 01:42:06 -07:00
namespace metaforce {
2018-12-07 21:30:43 -08:00
class CStopwatch {
private:
static CStopwatch mGlobalTimer;
2018-12-07 21:30:43 -08: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-18 23:10:54 -08: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-18 23:10:54 -08:00
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce