2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: TimerHighRes.hpp
|
|
|
|
Date: 2021-6-10
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Time
|
|
|
|
{
|
|
|
|
class TimerHighRes
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TimerHighRes()
|
|
|
|
{
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
start_ = CurrentInternalClockNS();
|
|
|
|
}
|
|
|
|
|
|
|
|
AuUInt64 End()
|
|
|
|
{
|
2022-02-19 17:56:45 +00:00
|
|
|
auto re = std::clamp<AuInt64>(CurrentInternalClockNS() - start_, AuInt64(0), AuNumericLimits<AuInt64>::max());
|
|
|
|
if (re == AuNumericLimits<AuInt64>::max()) return 0; // ez overflow in subtract. get out of here in 2-3 branches
|
2021-06-27 21:25:29 +00:00
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
AuUInt64 start_;
|
|
|
|
};
|
|
|
|
}
|