儲存庫 vbox 的更動 12546
- 時間撮記:
- 2008-9-17 下午05:11:15 (16 年 以前)
- 位置:
- trunk/src/VBox/Main
- 檔案:
-
- 修改 3 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/include/Performance.h
r12513 r12546 86 86 87 87 CollectorHints() : mHostFlags(COLLECT_NONE) {} 88 void collectHostCpuLoad() { mHostFlags |= COLLECT_CPU_LOAD; } 89 void collectHostRamUsage() { mHostFlags |= COLLECT_RAM_USAGE; } 88 void collectHostCpuLoad() 89 { mHostFlags |= COLLECT_CPU_LOAD; } 90 void collectHostRamUsage() 91 { mHostFlags |= COLLECT_RAM_USAGE; } 90 92 void collectProcessCpuLoad(RTPROCESS process) 91 { 92 findProcess(process).second |= COLLECT_CPU_LOAD; 93 } 93 { findProcess(process).second |= COLLECT_CPU_LOAD; } 94 94 void collectProcessRamUsage(RTPROCESS process) 95 {96 findProcess(process).second |= COLLECT_RAM_USAGE;97 }98 bool isHost CpuLoadCollected() { return (mHostFlags & COLLECT_CPU_LOAD) != 0; }99 bool isHostRamUsageCollected(){ return (mHostFlags & COLLECT_RAM_USAGE) != 0; }95 { findProcess(process).second |= COLLECT_RAM_USAGE; } 96 bool isHostCpuLoadCollected() const 97 { return (mHostFlags & COLLECT_CPU_LOAD) != 0; } 98 bool isHostRamUsageCollected() const 99 { return (mHostFlags & COLLECT_RAM_USAGE) != 0; } 100 100 bool isProcessCpuLoadCollected(RTPROCESS process) 101 { 102 return (findProcess(process).second & COLLECT_CPU_LOAD) != 0; 103 } 101 { return (findProcess(process).second & COLLECT_CPU_LOAD) != 0; } 104 102 bool isProcessRamUsageCollected(RTPROCESS process) 105 { 106 return (findProcess(process).second & COLLECT_RAM_USAGE) != 0; 107 } 103 { return (findProcess(process).second & COLLECT_RAM_USAGE) != 0; } 108 104 void getProcesses(std::vector<RTPROCESS>& processes) const 109 105 { -
trunk/src/VBox/Main/linux/PerformanceLinux.cpp
r12400 r12546 27 27 #include <iprt/param.h> 28 28 #include <iprt/string.h> 29 30 #include <map> 31 #include <vector> 32 33 #include "Logging.h" 29 34 #include "Performance.h" 30 35 … … 34 39 { 35 40 public: 41 virtual int preCollect(const CollectorHints& hints); 36 42 virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available); 37 43 virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used); … … 40 46 virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total); 41 47 private: 48 virtual int _getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle); 42 49 int getRawProcessStats(RTPROCESS process, uint64_t *cpuUser, uint64_t *cpuKernel, ULONG *memPagesUsed); 50 51 struct VMProcessStats 52 { 53 uint64_t cpuUser; 54 uint64_t cpuKernel; 55 ULONG pagesUsed; 56 }; 57 58 typedef std::map<RTPROCESS, VMProcessStats> VMProcessMap; 59 60 VMProcessMap mProcessStats; 61 uint64_t mUser, mKernel, mIdle; 43 62 }; 44 63 … … 50 69 // Collector HAL for Linux 51 70 52 int CollectorLinux::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle) 71 int CollectorLinux::preCollect(const CollectorHints& hints) 72 { 73 std::vector<RTPROCESS> processes; 74 hints.getProcesses(processes); 75 76 std::vector<RTPROCESS>::iterator it; 77 for(it = processes.begin(); it != processes.end(); it++) 78 { 79 VMProcessStats vmStats; 80 int rc = getRawProcessStats(*it, &vmStats.cpuUser, &vmStats.cpuKernel, &vmStats.pagesUsed); 81 if (RT_FAILURE(rc)) 82 return rc; 83 mProcessStats[*it] = vmStats; 84 } 85 if (hints.isHostCpuLoadCollected() || mProcessStats.size()) 86 { 87 _getRawHostCpuLoad(&mUser, &mKernel, &mIdle); 88 } 89 return VINF_SUCCESS; 90 } 91 92 int CollectorLinux::_getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle) 53 93 { 54 94 int rc = VINF_SUCCESS; … … 74 114 } 75 115 116 int CollectorLinux::getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle) 117 { 118 *user = mUser; 119 *kernel = mKernel; 120 *idle = mIdle; 121 return VINF_SUCCESS; 122 } 123 76 124 int CollectorLinux::getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total) 77 125 { 78 int rc = VINF_SUCCESS; 79 uint64_t uHostUser, uHostKernel, uHostIdle; 80 81 rc = getRawHostCpuLoad(&uHostUser, &uHostKernel, &uHostIdle); 82 if (RT_SUCCESS(rc)) 83 { 84 ULONG ulTmp; 85 *total = (uint64_t)uHostUser + uHostKernel + uHostIdle; 86 rc = getRawProcessStats(process, user, kernel, &ulTmp); 87 } 88 89 return rc; 126 VMProcessMap::const_iterator it = mProcessStats.find(process); 127 128 if (it == mProcessStats.end()) 129 { 130 Log (("No stats pre-collected for process %x\n", process)); 131 return VERR_INTERNAL_ERROR; 132 } 133 *user = it->second.cpuUser; 134 *kernel = it->second.cpuKernel; 135 *total = mUser + mKernel + mIdle; 136 return VINF_SUCCESS; 90 137 } 91 138 … … 119 166 int CollectorLinux::getProcessMemoryUsage(RTPROCESS process, ULONG *used) 120 167 { 121 uint64_t u64Tmp;122 ULONG nPagesUsed; 123 i nt rc = getRawProcessStats(process, &u64Tmp, &u64Tmp, &nPagesUsed);124 if (RT_SUCCESS(rc))125 {126 Assert(PAGE_SIZE >= 1024);127 *used = nPagesUsed * (PAGE_SIZE / 1024);128 }129 return rc;168 VMProcessMap::const_iterator it = mProcessStats.find(process); 169 170 if (it == mProcessStats.end()) 171 { 172 Log (("No stats pre-collected for process %x\n", process)); 173 return VERR_INTERNAL_ERROR; 174 } 175 *used = it->second.pagesUsed * (PAGE_SIZE / 1024); 176 return VINF_SUCCESS; 130 177 } 131 178 -
trunk/src/VBox/Main/testcase/tstCollector.cpp
r12513 r12546 51 51 #endif 52 52 53 pm::CollectorHAL *createCollector()54 {55 #ifdef RT_OS_SOLARIS56 return new pm::CollectorSolaris();57 #endif58 #ifdef RT_OS_LINUX59 return new pm::CollectorLinux();60 #endif61 #ifdef RT_OS_WINDOWS62 return new pm::CollectorWin();63 #endif64 #ifdef RT_OS_OS265 return new pm::CollectorOS2();66 #endif67 #ifdef RT_OS_DARWIN68 return new pm::CollectorDarwin();69 #endif70 return 0;71 }72 73 53 #define RUN_TIME_MS 1000 74 54 … … 128 108 uint64_t start; 129 109 unsigned int nCalls; 130 uint32_t totalTime = 0;131 110 /* Pre-collect */ 132 111 CALLS_PER_SECOND(preCollect(hints)); … … 199 178 #endif 200 179 201 pm::CollectorHAL *collector = createCollector();180 pm::CollectorHAL *collector = pm::createHAL(); 202 181 if (!collector) 203 182 {
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器