Changeset 43629 in vbox for trunk/src/VBox/Main/src-server/Performance.cpp
- Timestamp:
- Oct 12, 2012 9:26:07 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 81354
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/Performance.cpp
r43618 r43629 64 64 } 65 65 66 int CollectorHAL::getRawHostDiskLoad(const char * /* name */, uint64_t * /* disk_ms */, uint64_t * /* total_ms */) 67 { 68 return E_NOTIMPL; 69 } 70 66 71 int CollectorHAL::getRawProcessCpuLoad(RTPROCESS /* process */, uint64_t * /* user */, uint64_t * /* kernel */, uint64_t * /* total */) 67 72 { … … 70 75 71 76 int CollectorHAL::getHostMemoryUsage(ULONG * /* total */, ULONG * /* used */, ULONG * /* available */) 77 { 78 return E_NOTIMPL; 79 } 80 81 int CollectorHAL::getHostFilesystemUsage(const char * /* name */, ULONG * /* total */, ULONG * /* used */, ULONG * /* available */) 72 82 { 73 83 return E_NOTIMPL; … … 705 715 } 706 716 717 void HostDiskLoadRaw::init(ULONG period, ULONG length) 718 { 719 mPeriod = period; 720 mLength = length; 721 mUtil->init(mLength); 722 int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &mDiskPrev, &mTotalPrev); 723 AssertRC(rc); 724 } 725 726 void HostDiskLoadRaw::preCollect(CollectorHints& hints, uint64_t /* iTick */) 727 { 728 hints.collectHostCpuLoad(); 729 } 730 731 void HostDiskLoadRaw::collect() 732 { 733 uint64_t disk, total; 734 735 int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &disk, &total); 736 if (RT_SUCCESS(rc)) 737 { 738 uint64_t diskDiff = disk - mDiskPrev; 739 uint64_t totalDiff = total - mTotalPrev; 740 741 if (RT_UNLIKELY(totalDiff == 0)) 742 { 743 Assert(totalDiff); 744 LogFlowThisFunc(("Improbable! Less than millisecond passed! Disk=%s\n", mDiskName.c_str())); 745 mUtil->put(0); 746 } 747 else if (diskDiff > totalDiff) 748 { 749 /* 750 * It is possible that the disk spent more time than CPU because 751 * CPU measurements are taken during the pre-collect phase. We try 752 * to compensate for than by adding the extra to the next round of 753 * measurements. 754 */ 755 mUtil->put(PM_NETWORK_LOAD_MULTIPLIER); 756 Assert((diskDiff - totalDiff) < mPeriod * 1000); 757 if ((diskDiff - totalDiff) > mPeriod * 1000) 758 { 759 LogRel(("Disk utilization time exceeds CPU time by more" 760 " than the collection period (%llu ms)\n", diskDiff - totalDiff)); 761 } 762 else 763 { 764 disk = mDiskPrev + totalDiff; 765 LogFlowThisFunc(("Moved %u milliseconds to the next period.\n", (unsigned)(diskDiff - totalDiff))); 766 } 767 } 768 else 769 { 770 mUtil->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * diskDiff / totalDiff)); 771 } 772 773 mDiskPrev = disk; 774 mTotalPrev = total; 775 } 776 else 777 LogFlowThisFunc(("Failed to collect data: %Rrc (%d).\n", rc)); 778 } 779 707 780 void HostCpuMhz::init(ULONG period, ULONG length) 708 781 { … … 738 811 ULONG total, used, available; 739 812 int rc = mHAL->getHostMemoryUsage(&total, &used, &available); 813 if (RT_SUCCESS(rc)) 814 { 815 mTotal->put(total); 816 mUsed->put(used); 817 mAvailable->put(available); 818 819 } 820 } 821 822 void HostFilesystemUsage::init(ULONG period, ULONG length) 823 { 824 mPeriod = period; 825 mLength = length; 826 mTotal->init(mLength); 827 mUsed->init(mLength); 828 mAvailable->init(mLength); 829 } 830 831 void HostFilesystemUsage::preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) 832 { 833 } 834 835 void HostFilesystemUsage::collect() 836 { 837 ULONG total, used, available; 838 int rc = mHAL->getHostFilesystemUsage(mFsName.c_str(), &total, &used, &available); 740 839 if (RT_SUCCESS(rc)) 741 840 {
Note:
See TracChangeset
for help on using the changeset viewer.