MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / hashPush

Method hashPush

Engine/source/platform/profiler.cpp:292–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291#endif
292void Profiler::hashPush(ProfilerRootData *root)
293{
294#ifdef TORQUE_MULTITHREAD
295 // Ignore non-main-thread profiler activity.
296 if( !ThreadManager::isMainThread() )
297 return;
298#endif
299
300 mStackDepth++;
301 PROFILER_DEBUG_PUSH_NODE(root->mName);
302 AssertFatal(mStackDepth <= mMaxStackDepth,
303 "Stack overflow in profiler. You may have mismatched PROFILE_START and PROFILE_ENDs");
304 if(!mEnabled)
305 return;
306
307 ProfilerData *nextProfiler = NULL;
308 if(!root->mEnabled || mCurrentProfilerData->mRoot == root)
309 {
310 mCurrentProfilerData->mSubDepth++;
311 return;
312 }
313
314 if(mCurrentProfilerData->mLastSeenProfiler &&
315 mCurrentProfilerData->mLastSeenProfiler->mRoot == root)
316 nextProfiler = mCurrentProfilerData->mLastSeenProfiler;
317
318 if(!nextProfiler)
319 {
320 // first see if it's in the hash table...
321 U32 index = root->mNameHash & (ProfilerData::HashTableSize - 1);
322 nextProfiler = mCurrentProfilerData->mChildHash[index];
323 while(nextProfiler)
324 {
325 if(nextProfiler->mRoot == root)
326 break;
327 nextProfiler = nextProfiler->mNextHash;
328 }
329 if(!nextProfiler)
330 {
331 nextProfiler = (ProfilerData *) malloc(sizeof(ProfilerData));
332 for(U32 i = 0; i < ProfilerData::HashTableSize; i++)
333 nextProfiler->mChildHash[i] = 0;
334
335 nextProfiler->mRoot = root;
336 nextProfiler->mNextForRoot = root->mFirstProfilerData;
337 root->mFirstProfilerData = nextProfiler;
338
339 nextProfiler->mNextProfilerData = mProfileList;
340 mProfileList = nextProfiler;
341
342 nextProfiler->mNextHash = mCurrentProfilerData->mChildHash[index];
343 mCurrentProfilerData->mChildHash[index] = nextProfiler;
344
345 nextProfiler->mParent = mCurrentProfilerData;
346 nextProfiler->mNextSibling = mCurrentProfilerData->mFirstChild;
347 mCurrentProfilerData->mFirstChild = nextProfiler;
348 nextProfiler->mFirstChild = NULL;
349 nextProfiler->mLastSeenProfiler = NULL;

Callers 1

ScopedProfilerMethod · 0.80

Calls 2

isMainThreadFunction · 0.85
startHighResolutionTimerFunction · 0.85

Tested by

no test coverage detected