mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
Make frame timing logs opt-in
This commit is contained in:
parent
6d55c19987
commit
f4d947fab1
1 changed files with 18 additions and 3 deletions
|
|
@ -58,6 +58,15 @@
|
||||||
namespace wowee {
|
namespace wowee {
|
||||||
namespace core {
|
namespace core {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
bool envFlagEnabled(const char* key, bool defaultValue = false) {
|
||||||
|
const char* raw = std::getenv(key);
|
||||||
|
if (!raw || !*raw) return defaultValue;
|
||||||
|
return !(raw[0] == '0' || raw[0] == 'f' || raw[0] == 'F' ||
|
||||||
|
raw[0] == 'n' || raw[0] == 'N');
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
const char* Application::mapIdToName(uint32_t mapId) {
|
const char* Application::mapIdToName(uint32_t mapId) {
|
||||||
switch (mapId) {
|
switch (mapId) {
|
||||||
|
|
@ -221,6 +230,10 @@ bool Application::initialize() {
|
||||||
|
|
||||||
void Application::run() {
|
void Application::run() {
|
||||||
LOG_INFO("Starting main loop");
|
LOG_INFO("Starting main loop");
|
||||||
|
const bool frameProfileEnabled = envFlagEnabled("WOWEE_FRAME_PROFILE", false);
|
||||||
|
if (frameProfileEnabled) {
|
||||||
|
LOG_INFO("Frame timing profile enabled (WOWEE_FRAME_PROFILE=1)");
|
||||||
|
}
|
||||||
|
|
||||||
auto lastTime = std::chrono::high_resolution_clock::now();
|
auto lastTime = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
|
@ -362,9 +375,11 @@ void Application::run() {
|
||||||
totalSwapMs += std::chrono::duration<double, std::milli>(t4 - t3).count();
|
totalSwapMs += std::chrono::duration<double, std::milli>(t4 - t3).count();
|
||||||
|
|
||||||
if (++frameCount >= 60) {
|
if (++frameCount >= 60) {
|
||||||
LOG_INFO("[Frame] Update: ", totalUpdateMs / 60.0,
|
if (frameProfileEnabled && core::Logger::getInstance().shouldLog(core::LogLevel::DEBUG)) {
|
||||||
"ms Render: ", totalRenderMs / 60.0,
|
LOG_DEBUG("[Frame] Update: ", totalUpdateMs / 60.0,
|
||||||
"ms Swap: ", totalSwapMs / 60.0, "ms");
|
"ms Render: ", totalRenderMs / 60.0,
|
||||||
|
"ms Swap: ", totalSwapMs / 60.0, "ms");
|
||||||
|
}
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
totalUpdateMs = totalRenderMs = totalSwapMs = 0;
|
totalUpdateMs = totalRenderMs = totalSwapMs = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue