AuroraRuntime/Include/Aurora/Time/Stopwatch.hpp

53 lines
999 B
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Stopwatch.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
namespace Aurora::Time
{
AUKN_SYM AuUInt64 SteadyClockNS();
struct Stopwatch
{
inline Stopwatch()
{
Start();
}
inline ~Stopwatch()
{
}
inline void Start()
{
this->start_ = SteadyClockNS();
}
inline void Reset()
{
this->start_ = SteadyClockNS();
this->end_ = 0;
}
inline AuUInt64 EndNS()
{
if (!this->end_) this->end_ = SteadyClockNS();
return this->end_ - this->start_;
}
inline AuUInt64 EndMS()
{
if (!this->end_) this->end_ = SteadyClockNS();
return AuNSToMS<AuUInt64>(this->end_ - this->start_);
}
private:
AuUInt64 start_ {};
AuUInt64 end_ {};
};
}