儲存庫 vbox 的更動 12085
- 時間撮記:
- 2008-9-4 上午11:50:30 (16 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/testcase/tstCollector.cpp
r11822 r12085 34 34 #endif 35 35 #ifdef RT_OS_WINDOWS 36 #define _WIN32_DCOM 37 #include <objidl.h> 38 #include <objbase.h> 36 39 #include "../win/PerformanceWin.cpp" 37 40 #endif … … 62 65 return 0; 63 66 } 67 68 #define CALLS_PER_SECOND(fn) \ 69 nCalls = 0; \ 70 start = RTTimeMilliTS(); \ 71 do { \ 72 rc = collector->fn; \ 73 ++nCalls; \ 74 } while(RTTimeMilliTS() - start < 1000); \ 75 if (RT_FAILURE(rc)) \ 76 { \ 77 RTPrintf("tstCollector: "#fn" -> %Vrc\n", rc); \ 78 return 1; \ 79 } \ 80 RTPrintf("%50s -- %u calls per second\n", #fn, nCalls) 64 81 65 82 int main(int argc, char *argv[]) … … 75 92 return 1; 76 93 } 94 #ifdef RT_OS_WINDOWS 95 HRESULT hRes = CoInitialize(NULL); 96 /* 97 * Need to initialize security to access performance enumerators. 98 */ 99 hRes = CoInitializeSecurity( 100 NULL, 101 -1, 102 NULL, 103 NULL, 104 RPC_C_AUTHN_LEVEL_NONE, 105 RPC_C_IMP_LEVEL_IMPERSONATE, 106 NULL, EOAC_NONE, 0); 107 #endif 108 109 uint64_t start; 77 110 78 111 pm::CollectorHAL *collector = createCollector(); … … 82 115 return 1; 83 116 } 84 117 #if 1 85 118 uint64_t hostUserStart, hostKernelStart, hostIdleStart; 86 119 uint64_t hostUserStop, hostKernelStop, hostIdleStop, hostTotal; … … 140 173 return 1; 141 174 } 142 uint64_tstart = RTTimeMilliTS();175 start = RTTimeMilliTS(); 143 176 while(RTTimeMilliTS() - start < 5000); // Loop for 5 seconds 144 177 rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop); … … 183 216 RTPrintf("tstCollector: host mem available = %lu kB\n", available); 184 217 RTPrintf("tstCollector: process mem used = %lu kB\n", processUsed); 185 218 #endif 219 RTPrintf("\ntstCollector: TESTING - Performance\n\n"); 220 unsigned nCalls; 221 ULONG tmp; 222 uint64_t tmp64; 223 RTPROCESS pid = RTProcSelf(); 224 /* Host CPU load */ 225 CALLS_PER_SECOND(getRawHostCpuLoad(&tmp64, &tmp64, &tmp64)); 226 /* Process CPU load */ 227 CALLS_PER_SECOND(getRawProcessCpuLoad(pid, &tmp64, &tmp64, &tmp64)); 228 /* Host CPU speed */ 229 CALLS_PER_SECOND(getHostCpuMHz(&tmp)); 230 /* Host RAM usage */ 231 CALLS_PER_SECOND(getHostMemoryUsage(&tmp, &tmp, &tmp)); 232 /* Process RAM usage */ 233 CALLS_PER_SECOND(getProcessMemoryUsage(pid, &tmp)); 234 186 235 delete collector; 187 236 188 printf (" tstCollector FINISHED.\n");237 printf ("\ntstCollector FINISHED.\n"); 189 238 190 239 return rc;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器