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
53 lines
1.1 KiB
C++
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__); |