/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/UnitTests/FoundationTest/Profiling/ProfilingTest.cpp
55 строк
1 KB
Jan Krassnigg
Some ezFoundation changes (#1317)
04 июн 2024, 13:15
Не верифицирован
04 июн 2024, 13:15
ded6365
Код
Авторство
О чём код?
#include <FoundationTest/FoundationTestPCH.h> #include <Foundation/IO/FileSystem/FileSystem.h> #include <Foundation/IO/FileSystem/FileWriter.h> #include <Foundation/Profiling/Profiling.h> #include <Foundation/Threading/ThreadUtils.h> namespace { void WriteOutProfilingCapture(const char* szFilePath) { ezStringBuilder outputPath = ezTestFramework::GetInstance()->GetAbsOutputPath(); EZ_TEST_BOOL(ezFileSystem::AddDataDirectory(outputPath.GetData(), "test", "output", ezDataDirUsage::AllowWrites) == EZ_SUCCESS); ezFileWriter fileWriter; if (fileWriter.Open(szFilePath) == EZ_SUCCESS) { ezProfilingSystem::ProfilingData profilingData; ezProfilingSystem::Capture(profilingData); profilingData.Write(fileWriter).IgnoreResult(); ezLog::Info("Profiling capture saved to '{0}'.", fileWriter.GetFilePathAbsolute().GetData()); } } } // namespace EZ_CREATE_SIMPLE_TEST_GROUP(Profiling); EZ_CREATE_SIMPLE_TEST(Profiling, Profiling) { EZ_TEST_BLOCK(ezTestBlock::Enabled, "Nested scopes") { ezProfilingSystem::Clear(); { EZ_PROFILE_SCOPE("Prewarm scope"); ezThreadUtils::Sleep(ezTime::MakeFromMilliseconds(1)); } ezTime endTime = ezTime::Now() + ezTime::MakeFromMilliseconds(1); { EZ_PROFILE_SCOPE("Outer scope"); { EZ_PROFILE_SCOPE("Inner scope"); while (ezTime::Now() < endTime) { } } } WriteOutProfilingCapture(":output/profilingScopes.json"); } }