MCPcopy Create free account
hub / github.com/defold/defold / SampleTreeCallback

Function SampleTreeCallback

engine/profiler/src/profiler.cpp:900–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900static void SampleTreeCallback(void* _ctx, const char* thread_name, dmProfiler::HSample root)
901{
902 if (g_ProfilerCurrentFrame == 0) // Possibly in the process of shutting down
903 return;
904
905 // TODO: Make a better selection scheme, letting the user step through the threads one by one
906 bool valid = strcmp(thread_name, "Main") == 0 || strcmp(thread_name, "sound") == 0;
907 if (!valid)
908 {
909 return;
910 }
911
912 DM_MUTEX_SCOPED_LOCK(g_ProfilerMutex);
913
914 dmProfileRender::ProfilerFrame* frame = (dmProfileRender::ProfilerFrame*)_ctx;
915 frame->m_Time = dmTime::GetMonotonicTime();
916
917 // Prune old profiler threads
918 dmProfileRender::PruneProfilerThreads(frame, frame->m_Time - 150000);
919
920 uint32_t name_hash = dmHashString32(thread_name);
921 dmProfileRender::ProfilerThread* thread = dmProfileRender::FindOrCreateProfilerThread(frame, name_hash);
922 dmProfileRender::ClearProfilerThreadSamples(thread);
923
924 thread->m_Time = frame->m_Time;
925
926 thread->m_SamplesTotalTime = dmProfiler::SampleGetTime(root);
927
928 //printf("Thread: %s\n", thread_name);
929 TraverseSampleTree(thread, 0, root);
930}
931
932////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
933

Callers

nothing calls this directly

Calls 6

PruneProfilerThreadsFunction · 0.85
SampleGetTimeFunction · 0.85
TraverseSampleTreeFunction · 0.85
GetMonotonicTimeFunction · 0.50

Tested by

no test coverage detected