2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-11-19 07:10:54 +00:00
|
|
|
|
2022-02-26 16:42:42 +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 {
|
2022-02-26 16:42:42 +00:00
|
|
|
private:
|
|
|
|
static CStopwatch mGlobalTimer;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2022-02-26 16:42:42 +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;
|
2022-02-25 07:45:25 +00:00
|
|
|
|
2017-11-19 07:10:54 +00:00
|
|
|
public:
|
2022-02-26 16:42:42 +00:00
|
|
|
static void InitGlobalTimer();
|
|
|
|
static CStopwatch& GetGlobalTimerObj() { return mGlobalTimer; }
|
|
|
|
static float GetGlobalTime() { return mGlobalTimer.GetElapsedTime(); }
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void Wait(float wait);
|
2022-02-25 07:45:25 +00:00
|
|
|
|
2022-02-26 16:42:42 +00:00
|
|
|
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
|