Jamie Reece Wilson
83fad7c538
[+] AuTime::Clock<T>::GetFrequency(); where T = [+] AuTime::ClockWall [+] AuTime::ClockSteady [+] AuTime::ClockProcessTime [+] AuTime::ClockProcessKernelTime [+] AuTime::ClockProcessUserTime [+] AuTime::ClockThreadTime [+] AuTime::ClockThreadKernelTime [+] AuTime::ClockThreadUserTime
68 lines
1.3 KiB
C++
68 lines
1.3 KiB
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
|
|
|
|
#include "StaticClocksDirect.hpp"
|
|
#include "StaticClocksClasses.hpp"
|
|
|
|
namespace Aurora::Time
|
|
{
|
|
template <typename DefaultClock_t = ClockSteady>
|
|
struct Stopwatch
|
|
{
|
|
inline Stopwatch()
|
|
{
|
|
Start();
|
|
}
|
|
|
|
inline ~Stopwatch()
|
|
{
|
|
|
|
}
|
|
|
|
inline void Start()
|
|
{
|
|
this->qwStart_ = GetTimeInNanosecond();
|
|
}
|
|
|
|
inline void Reset()
|
|
{
|
|
this->qwStart_ = GetTimeInNanosecond();
|
|
this->qwEnd_ = 0;
|
|
}
|
|
|
|
inline AuUInt64 EndNS()
|
|
{
|
|
if (!this->qwEnd_)
|
|
{
|
|
this->qwEnd_ = GetTimeInNanosecond();
|
|
}
|
|
|
|
return this->qwEnd_ - this->qwStart_;
|
|
}
|
|
|
|
inline AuUInt64 EndMS()
|
|
{
|
|
if (!this->qwEnd_)
|
|
{
|
|
this->qwEnd_ = GetTimeInNanosecond();
|
|
}
|
|
|
|
return AuNSToMS<AuUInt64>(this->qwEnd_ - this->qwStart_);
|
|
}
|
|
|
|
private:
|
|
AuUInt64 qwStart_ {};
|
|
AuUInt64 qwEnd_ {};
|
|
|
|
inline AuUInt64 GetTimeInNanosecond()
|
|
{
|
|
return Clock<DefaultClock_t>::GetCurrentTimeNS();
|
|
}
|
|
};
|
|
} |