/*** 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 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 DebugBenchmark(T... args) {} inline void Finish() {} }; #endif } #define SysBenchmark(...) Aurora::Time::DebugBenchmark _(__VA_ARGS__);