| 437 | } |
| 438 | |
| 439 | void Profiler::hashPop(ProfilerRootData *expected) |
| 440 | { |
| 441 | #ifdef TORQUE_MULTITHREAD |
| 442 | // Ignore non-main-thread profiler activity. |
| 443 | if( !ThreadManager::isMainThread() ) |
| 444 | return; |
| 445 | #endif |
| 446 | |
| 447 | mStackDepth--; |
| 448 | PROFILER_DEBUG_POP_NODE(); |
| 449 | AssertFatal(mStackDepth >= 0, "Stack underflow in profiler. You may have mismatched PROFILE_START and PROFILE_ENDs"); |
| 450 | if(mEnabled) |
| 451 | { |
| 452 | if(mCurrentProfilerData->mSubDepth) |
| 453 | { |
| 454 | mCurrentProfilerData->mSubDepth--; |
| 455 | return; |
| 456 | } |
| 457 | |
| 458 | if(expected) |
| 459 | { |
| 460 | AssertISV(expected == mCurrentProfilerData->mRoot, "Profiler::hashPop - didn't get expected ProfilerRoot!"); |
| 461 | } |
| 462 | |
| 463 | F64 fElapsed = endHighResolutionTimer(mCurrentProfilerData->mStartTime); |
| 464 | |
| 465 | mCurrentProfilerData->mTotalTime += fElapsed; |
| 466 | mCurrentProfilerData->mParent->mSubTime += fElapsed; // mark it in the parent as well... |
| 467 | mCurrentProfilerData->mRoot->mTotalTime += fElapsed; |
| 468 | if(mCurrentProfilerData->mParent->mRoot) |
| 469 | mCurrentProfilerData->mParent->mRoot->mSubTime += fElapsed; // mark it in the parent as well... |
| 470 | |
| 471 | mCurrentProfilerData = mCurrentProfilerData->mParent; |
| 472 | } |
| 473 | if(mStackDepth == 0) |
| 474 | { |
| 475 | // apply the next enable... |
| 476 | if(mDumpToConsole || mDumpToFile) |
| 477 | { |
| 478 | dump(); |
| 479 | startHighResolutionTimer(mCurrentProfilerData->mStartTime); |
| 480 | } |
| 481 | if(!mEnabled && mNextEnable) |
| 482 | startHighResolutionTimer(mCurrentProfilerData->mStartTime); |
| 483 | |
| 484 | #if defined(TORQUE_OS_WIN) |
| 485 | // The high performance counters under win32 are unreliable when running on multiple |
| 486 | // processors. When the profiler is enabled, we restrict Torque to a single processor. |
| 487 | if(mNextEnable != mEnabled) |
| 488 | { |
| 489 | |
| 490 | if(mNextEnable) |
| 491 | { |
| 492 | Con::warnf("Warning: forcing the Torque profiler thread to run only on cpu 1."); |
| 493 | SetThreadAffinityMask(GetCurrentThread(), 1); |
| 494 | } |
| 495 | else |
| 496 | { |
no test coverage detected