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

Method hashPush

Engine/source/platform/profiler.cpp:344–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343#endif
344void Profiler::hashPush(ProfilerRootData *root)
345{
346#ifdef TORQUE_MULTITHREAD
347 // Ignore non-main-thread profiler activity.
348 if( !ThreadManager::isMainThread() )
349 return;
350#endif
351
352 mStackDepth++;
353 PROFILER_DEBUG_PUSH_NODE(root->mName);
354 AssertFatal(mStackDepth <= mMaxStackDepth,
355 "Stack overflow in profiler. You may have mismatched PROFILE_START and PROFILE_ENDs");
356 if(!mEnabled)
357 return;
358
359 ProfilerData *nextProfiler = NULL;
360 if(!root->mEnabled || mCurrentProfilerData->mRoot == root)
361 {
362 mCurrentProfilerData->mSubDepth++;
363 return;
364 }
365
366 if(mCurrentProfilerData->mLastSeenProfiler &&
367 mCurrentProfilerData->mLastSeenProfiler->mRoot == root)
368 nextProfiler = mCurrentProfilerData->mLastSeenProfiler;
369
370 if(!nextProfiler)
371 {
372 // first see if it's in the hash table...
373 U32 index = root->mNameHash & (ProfilerData::HashTableSize - 1);
374 nextProfiler = mCurrentProfilerData->mChildHash[index];
375 while(nextProfiler)
376 {
377 if(nextProfiler->mRoot == root)
378 break;
379 nextProfiler = nextProfiler->mNextHash;
380 }
381 if(!nextProfiler)
382 {
383 nextProfiler = (ProfilerData *) malloc(sizeof(ProfilerData));
384 for(U32 i = 0; i < ProfilerData::HashTableSize; i++)
385 nextProfiler->mChildHash[i] = 0;
386
387 nextProfiler->mRoot = root;
388 nextProfiler->mNextForRoot = root->mFirstProfilerData;
389 root->mFirstProfilerData = nextProfiler;
390
391 nextProfiler->mNextProfilerData = mProfileList;
392 mProfileList = nextProfiler;
393
394 nextProfiler->mNextHash = mCurrentProfilerData->mChildHash[index];
395 mCurrentProfilerData->mChildHash[index] = nextProfiler;
396
397 nextProfiler->mParent = mCurrentProfilerData;
398 nextProfiler->mNextSibling = mCurrentProfilerData->mFirstChild;
399 mCurrentProfilerData->mFirstChild = nextProfiler;
400 nextProfiler->mFirstChild = NULL;
401 nextProfiler->mLastSeenProfiler = NULL;

Callers 1

ScopedProfilerMethod · 0.80

Calls 2

isMainThreadFunction · 0.85
startHighResolutionTimerFunction · 0.85

Tested by

no test coverage detected