| 542 | } |
| 543 | |
| 544 | void Profiler::dump() |
| 545 | { |
| 546 | bool enableSave = mEnabled; |
| 547 | mEnabled = false; |
| 548 | mStackDepth++; |
| 549 | // may have some profiled calls... gotta turn em off. |
| 550 | |
| 551 | Vector<ProfilerRootData *> rootVector; |
| 552 | F64 totalTime = 0; |
| 553 | for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) |
| 554 | { |
| 555 | totalTime += walk->mTotalTime - walk->mSubTime; |
| 556 | rootVector.push_back(walk); |
| 557 | } |
| 558 | dQsort((void *) &rootVector[0], rootVector.size(), sizeof(ProfilerRootData *), rootDataCompare); |
| 559 | |
| 560 | |
| 561 | if (mDumpToConsole == true) |
| 562 | { |
| 563 | Con::printf("Profiler Data Dump:"); |
| 564 | Con::printf("Ordered by non-sub total time -"); |
| 565 | Con::printf("%%NSTime %% Time Invoke # Name"); |
| 566 | for(U32 i = 0; i < rootVector.size(); i++) |
| 567 | { |
| 568 | Con::printf("%7.3f %7.3f %8d %s", |
| 569 | 100 * (rootVector[i]->mTotalTime - rootVector[i]->mSubTime) / totalTime, |
| 570 | 100 * rootVector[i]->mTotalTime / totalTime, |
| 571 | rootVector[i]->mTotalInvokeCount, |
| 572 | rootVector[i]->mName); |
| 573 | rootVector[i]->mTotalInvokeCount = 0; |
| 574 | rootVector[i]->mTotalTime = 0; |
| 575 | rootVector[i]->mSubTime = 0; |
| 576 | } |
| 577 | Con::printf(""); |
| 578 | Con::printf("Ordered by stack trace total time -"); |
| 579 | Con::printf("%% Time %% NSTime Invoke # Name"); |
| 580 | |
| 581 | mCurrentProfilerData->mTotalTime = endHighResolutionTimer(mCurrentProfilerData->mStartTime); |
| 582 | |
| 583 | char depthBuffer[MaxStackDepth * 2 + 1]; |
| 584 | depthBuffer[0] = 0; |
| 585 | profilerDataDumpRecurse(mCurrentProfilerData, depthBuffer, 0, totalTime); |
| 586 | mEnabled = enableSave; |
| 587 | mStackDepth--; |
| 588 | } |
| 589 | else if (mDumpToFile == true && mDumpFileName[0] != '\0') |
| 590 | { |
| 591 | FileStream fws; |
| 592 | bool success = fws.open(mDumpFileName, Torque::FS::File::Write); |
| 593 | AssertFatal(success, "Cannot write profile dump to specified file!"); |
| 594 | char buffer[1024]; |
| 595 | |
| 596 | dStrcpy(buffer, "Profiler Data Dump:\n", 1024); |
| 597 | fws.write(dStrlen(buffer), buffer); |
| 598 | dStrcpy(buffer, "Ordered by non-sub total time -\n", 1024); |
| 599 | fws.write(dStrlen(buffer), buffer); |
| 600 | dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n", 1024); |
| 601 | fws.write(dStrlen(buffer), buffer); |
nothing calls this directly
no test coverage detected