/*** 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 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(this->qwEnd_ - this->qwStart_); } private: AuUInt64 qwStart_ {}; AuUInt64 qwEnd_ {}; inline AuUInt64 GetTimeInNanosecond() { return Clock::GetCurrentTimeNS(); } }; }