diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index a9175709fd..bb491391ae 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -781,7 +781,6 @@ void EarlyInit() // initialise profiler early so it can profile startup g_Profiler2.Initialise(); - g_Profiler2.RegisterCurrentThread("main"); FixLocales(); diff --git a/source/ps/Profiler2.cpp b/source/ps/Profiler2.cpp index a41000594f..be8d661ebf 100644 --- a/source/ps/Profiler2.cpp +++ b/source/ps/Profiler2.cpp @@ -129,6 +129,8 @@ void CProfiler2::Initialise() int err = pthread_key_create(&m_TLS, &CProfiler2::TLSDtor); ENSURE(err == 0); m_Initialised = true; + + RegisterCurrentThread("main"); } void CProfiler2::EnableHTTP() diff --git a/source/test_setup.cpp b/source/test_setup.cpp index 5a83253172..fd1be36179 100644 --- a/source/test_setup.cpp +++ b/source/test_setup.cpp @@ -35,6 +35,7 @@ #include "lib/timer.h" #include "lib/sysdep/sysdep.h" +#include "ps/Profiler2.h" #include "scriptinterface/ScriptInterface.h" class LeakReporter : public CxxTest::GlobalFixture @@ -77,9 +78,17 @@ class MiscSetup : public CxxTest::GlobalFixture setlocale(LC_CTYPE, "UTF-8"); #endif + g_Profiler2.Initialise(); + return true; } + virtual bool tearDownWorld() + { + g_Profiler2.Shutdown(); + + return true; + } }; static LeakReporter leakReporter; diff --git a/source/tools/atlas/GameInterface/GameLoop.cpp b/source/tools/atlas/GameInterface/GameLoop.cpp index 4bc3483e29..a1cda3a6d7 100644 --- a/source/tools/atlas/GameInterface/GameLoop.cpp +++ b/source/tools/atlas/GameInterface/GameLoop.cpp @@ -99,13 +99,15 @@ static void RendererIncrementalLoad() while (more && timer_Time() - startTime < maxTime); } -static void* RunEngine(void *data) +static void* RunEngine(void* data) { debug_SetThreadName("engine_thread"); // Set new main thread so that all the thread-safety checks pass ThreadUtil::SetMainThread(); + g_Profiler2.RegisterCurrentThread("atlasmain"); + const CmdLineArgs args = *reinterpret_cast(data); MessagePasserImpl* msgPasser = (MessagePasserImpl*)AtlasMessage::g_MessagePasser;