2023-03-21 10:05:45 +00:00
|
|
|
/***
|
|
|
|
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:
|
2023-03-22 17:12:11 +00:00
|
|
|
AuUInt64 start_ {};
|
|
|
|
AuUInt64 end_ {};
|
2023-03-21 10:05:45 +00:00
|
|
|
};
|
|
|
|
}
|