AuroraRuntime/Include/Aurora/Time/DebugBenchmark.hpp
Reece 82d455c4b1 [+] AuTime::EClock
[+] AuTime::IClock
[+] AuTime::GetWallClock
[+] AuTime::GetProcessClock
[+] AuTime::GetSteadyClock
[+] AuTime::GetClockFromEnum
[*] Rename Timer -> Stopwatch
[*] Refactor a serial AuString to a string view

(*amended year)
2023-03-21 10:26:16 +00: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 stopwatch_;
AuString message_;
};
#else
struct DebugBenchmark
{
template<typename ... T>
DebugBenchmark(T... args) {}
inline void Finish() {}
};
#endif
}
#define SysBenchmark(...) Aurora::Time::DebugBenchmark _(__VA_ARGS__);