| 495 | |
| 496 | |
| 497 | void Profiler::dump() |
| 498 | { |
| 499 | bool enableSave = mEnabled; |
| 500 | mEnabled = false; |
| 501 | mStackDepth++; |
| 502 | // may have some profiled calls... gotta turn em off. |
| 503 | |
| 504 | Vector<ProfilerRootData *> rootVector; |
| 505 | F64 totalTime = 0; |
| 506 | for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) |
| 507 | { |
| 508 | totalTime += walk->mTotalTime - walk->mSubTime; |
| 509 | rootVector.push_back(walk); |
| 510 | } |
| 511 | //-Mat no sort, makes it easier to compare |
| 512 | dQsort((void *)rootVector.address(), rootVector.size(), sizeof(ProfilerRootData *), rootDataCompare); |
| 513 | |
| 514 | |
| 515 | if (mDumpToConsole == true) |
| 516 | { |
| 517 | Con::printf("Profiler Data Dump:"); |
| 518 | Con::printf("Ordered by non-sub total time -"); |
| 519 | Con::printf("%%NSTime %% Time Invoke # Name"); |
| 520 | for(U32 i = 0; i < (U32)rootVector.size(); i++) |
| 521 | { |
| 522 | Con::printf("%7.3f %7.3f %8d %s", |
| 523 | 100 * (rootVector[i]->mTotalTime - rootVector[i]->mSubTime) / totalTime, |
| 524 | 100 * rootVector[i]->mTotalTime / totalTime, |
| 525 | rootVector[i]->mTotalInvokeCount, |
| 526 | rootVector[i]->mName); |
| 527 | rootVector[i]->mTotalInvokeCount = 0; |
| 528 | rootVector[i]->mTotalTime = 0; |
| 529 | rootVector[i]->mSubTime = 0; |
| 530 | } |
| 531 | Con::printf(""); |
| 532 | Con::printf("Ordered by stack trace total time -"); |
| 533 | Con::printf("%% Time %% NSTime Invoke # Name"); |
| 534 | |
| 535 | mCurrentProfilerData->mTotalTime = endHighResolutionTimer(mCurrentProfilerData->mStartTime); |
| 536 | |
| 537 | char depthBuffer[MaxStackDepth * 2 + 1]; |
| 538 | depthBuffer[0] = 0; |
| 539 | profilerDataDumpRecurse(mCurrentProfilerData, depthBuffer, 0, totalTime); |
| 540 | mEnabled = enableSave; |
| 541 | mStackDepth--; |
| 542 | } |
| 543 | else if (mDumpToFile == true && mDumpFileName[0] != '\0') |
| 544 | { |
| 545 | FileStream fws; |
| 546 | bool success = fws.open(mDumpFileName, FileStream::Write); |
| 547 | AssertFatal(success, "Nuts! Cannot write profile dump to specified file!"); |
| 548 | char buffer[1024]; |
| 549 | |
| 550 | dStrcpy(buffer, "Profiler Data Dump:\n"); |
| 551 | fws.write(dStrlen(buffer), buffer); |
| 552 | dStrcpy(buffer, "Ordered by non-sub total time -\n"); |
| 553 | fws.write(dStrlen(buffer), buffer); |
| 554 | dStrcpy(buffer, "%%NSTime %% Time Invoke # Name\n"); |
nothing calls this directly
no test coverage detected