/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/EnginePlugins/InspectorPlugin/InspectorApp.cpp
101 строка
3 KB
Jan Krassnigg
GAL improvements (#1422)
05 ноя 2024, 22:46
Не верифицирован
05 ноя 2024, 22:46
0e9f0e4
Код
Авторство
О чём код?
#include <InspectorPlugin/InspectorPluginPCH.h> #include <Foundation/Communication/Telemetry.h> #include <Foundation/System/SystemInformation.h> #include <Foundation/Threading/Thread.h> #include <Foundation/Utilities/Stats.h> static ezAssertHandler g_PreviousAssertHandler = nullptr; static bool TelemetryAssertHandler(const char* szSourceFile, ezUInt32 uiLine, const char* szFunction, const char* szExpression, const char* szAssertMsg) { if (ezTelemetry::IsConnectedToClient()) { ezTelemetryMessage msg; msg.SetMessageID(' APP', 'ASRT'); msg.GetWriter() << szSourceFile; msg.GetWriter() << uiLine; msg.GetWriter() << szFunction; msg.GetWriter() << szExpression; msg.GetWriter() << szAssertMsg; ezTelemetry::Broadcast(ezTelemetry::Reliable, msg); // messages might not arrive, if the network does not get enough time to transmit them // since we are crashing the application in (half) 'a second', we need to make sure the network traffic has indeed been sent for (ezUInt32 i = 0; i < 5; ++i) { ezThreadUtils::Sleep(ezTime::MakeFromMilliseconds(100)); ezTelemetry::UpdateNetwork(); } } if (g_PreviousAssertHandler) return g_PreviousAssertHandler(szSourceFile, uiLine, szFunction, szExpression, szAssertMsg); return true; } void AddTelemetryAssertHandler() { g_PreviousAssertHandler = ezGetAssertHandler(); ezSetAssertHandler(TelemetryAssertHandler); } void RemoveTelemetryAssertHandler() { ezSetAssertHandler(g_PreviousAssertHandler); g_PreviousAssertHandler = nullptr; } void SetAppStats() { ezStringBuilder sOut; const ezSystemInformation info = ezSystemInformation::Get(); ezStats::SetStat("Platform/Name", info.GetPlatformName()); ezStats::SetStat("Hardware/CPU Cores", info.GetCPUCoreCount()); ezStats::SetStat("Hardware/RAM[GB]", info.GetInstalledMainMemory() / 1024.0f / 1024.0f / 1024.0f); sOut = info.Is64BitOS() ? "64 Bit" : "32 Bit"; ezStats::SetStat("Platform/Architecture", sOut.GetData()); #if EZ_ENABLED(EZ_COMPILE_FOR_DEBUG) sOut = "Debug"; #elif EZ_ENABLED(EZ_COMPILE_FOR_DEVELOPMENT) sOut = "Dev"; #else sOut = "Release"; #endif ezStats::SetStat("Platform/Build", sOut.GetData()); #if EZ_ENABLED(EZ_USE_PROFILING) sOut = "Enabled"; #else sOut = "Disabled"; #endif ezStats::SetStat("Features/Profiling", sOut.GetData()); if constexpr (ezAllocatorTrackingMode::Default >= ezAllocatorTrackingMode::AllocationStats) sOut = "Enabled"; else sOut = "Disabled"; ezStats::SetStat("Features/Allocation Tracking", sOut.GetData()); if constexpr (ezAllocatorTrackingMode::Default >= ezAllocatorTrackingMode::AllocationStatsAndStacktraces) sOut = "Enabled"; else sOut = "Disabled"; ezStats::SetStat("Features/Allocation Stack Tracing", sOut.GetData()); #if EZ_ENABLED(EZ_PLATFORM_LITTLE_ENDIAN) sOut = "Little"; #else sOut = "Big"; #endif ezStats::SetStat("Platform/Endianess", sOut.GetData()); }