AuroraRuntime/Include/Aurora/Time/DebugBenchmark.hpp
Jamie Reece Wilson 83fad7c538 [+] AuTime::Clock<T>::GetCurrentTimeNS();
[+] AuTime::Clock<T>::GetFrequency();
where T =
[+] AuTime::ClockWall
[+] AuTime::ClockSteady
[+] AuTime::ClockProcessTime
[+] AuTime::ClockProcessKernelTime
[+] AuTime::ClockProcessUserTime
[+] AuTime::ClockThreadTime
[+] AuTime::ClockThreadKernelTime
[+] AuTime::ClockThreadUserTime
2023-07-08 17:28:24 +01:00

53 lines
1.1 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: DebugBenchmark.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include <Aurora/Console/Console.hpp>
namespace Aurora::Time
{
#if ((defined(AU_FORCE_BENCHMARK) || defined(AU_CFG_ID_DEBUG) || defined(AU_CFG_ID_INTERNAL)) && (!defined(AU_FORCE_NOBENCHMARK)))
struct DebugBenchmark
{
inline DebugBenchmark(AuString &&message) : message_(AuMove(message))
{
this->stopwatch_.Start();
}
inline ~DebugBenchmark()
{
Finish();
}
inline void Finish()
{
auto uEndNS = this->stopwatch_.EndNS();
Aurora::Logging::LogDbg("[Benchmark] {} took {}", message_, ConvertNSToTimescale(uEndNS));
}
private:
Stopwatch<ClockSteady> stopwatch_;
AuString message_;
};
#else
struct DebugBenchmark
{
template<typename ... T>
DebugBenchmark(T... args) {}
inline void Finish() {}
};
#endif
}
#define SysBenchmark(...) Aurora::Time::DebugBenchmark _(__VA_ARGS__);