Changeset 43629 in vbox for trunk/src/VBox/Main/testcase
- 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/testcase/tstCollector.cpp
r43538 r43629 153 153 uint64_t hostRxStop, hostTxStop, speed = 125000000; /* Assume 1Gbit/s */ 154 154 155 RTPrintf(" \ntstCollector: TESTING - Network load, sleeping for 5 sec...\n");155 RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 sec...\n"); 156 156 157 157 int rc = collector->preCollect(hints, 0); … … 184 184 RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n", 185 185 speed, speed/(1000000/8)); 186 RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, % d %%*100)\n",186 RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n", 187 187 (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8), 188 (hostRxStop - hostRxStart) * 10000 / (speed * 5)); 189 RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %d %%*100)\n", 188 (hostRxStop - hostRxStart) * 100 / (speed * 5), 189 (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100); 190 RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n", 190 191 (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8), 191 (hostTxStop - hostTxStart) * 10000 / (speed * 5)); 192 (hostTxStop - hostTxStart) * 100 / (speed * 5), 193 (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100); 192 194 193 195 return 0; 194 196 } 197 198 #define FSNAME "/" 199 int testFsUsage(pm::CollectorHAL *collector) 200 { 201 RTPrintf("tstCollector: TESTING - File system usage\n"); 202 203 ULONG total, used, available; 204 205 int rc = collector->getHostFilesystemUsage(FSNAME, &total, &used, &available); 206 if (RT_FAILURE(rc)) 207 { 208 RTPrintf("tstCollector: getHostFilesystemUsage() -> %Rrc\n", rc); 209 return 1; 210 } 211 RTPrintf("tstCollector: host root fs total = %lu mB\n", total); 212 RTPrintf("tstCollector: host root fs used = %lu mB\n", used); 213 RTPrintf("tstCollector: host root fs available = %lu mB\n\n", available); 214 return 0; 215 } 216 217 int testDisk(pm::CollectorHAL *collector) 218 { 219 pm::CollectorHints hints; 220 uint64_t diskMsStart, totalMsStart; 221 uint64_t diskMsStop, totalMsStop; 222 223 std::list<RTCString> disks; 224 int rc = pm::getDiskListByFs(FSNAME, disks); 225 if (RT_FAILURE(rc)) 226 { 227 RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc); 228 return 1; 229 } 230 if (disks.empty()) 231 { 232 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty list\n", FSNAME); 233 return 1; 234 } 235 236 RTPrintf("tstCollector: TESTING - Disk utilization, sleeping for 5 sec...\n"); 237 238 hints.collectHostCpuLoad(); 239 rc = collector->preCollect(hints, 0); 240 if (RT_FAILURE(rc)) 241 { 242 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 243 return 1; 244 } 245 rc = collector->getRawHostDiskLoad(disks.front().c_str(), &diskMsStart, &totalMsStart); 246 if (RT_FAILURE(rc)) 247 { 248 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 249 return 1; 250 } 251 252 RTThreadSleep(5000); // Sleep for five seconds 253 254 rc = collector->preCollect(hints, 0); 255 if (RT_FAILURE(rc)) 256 { 257 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc); 258 return 1; 259 } 260 rc = collector->getRawHostDiskLoad(disks.front().c_str(), &diskMsStop, &totalMsStop); 261 if (RT_FAILURE(rc)) 262 { 263 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc); 264 return 1; 265 } 266 RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n", 267 (diskMsStop - diskMsStart), 268 (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)), 269 (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100), 270 totalMsStop - totalMsStart); 271 272 return 0; 273 } 274 275 195 276 196 277 int main(int argc, char *argv[]) … … 296 377 printf("tstCollector: host cpu idle = %f sec\n", (hostIdleStop - hostIdleStart) / 10000000.); 297 378 printf("tstCollector: host cpu total = %f sec\n", hostTotal / 10000000.);*/ 298 RTPrintf("tstCollector: host cpu user = %llu %%\n", (hostUserStop - hostUserStart) * 100 / hostTotal); 299 RTPrintf("tstCollector: host cpu kernel = %llu %%\n", (hostKernelStop - hostKernelStart) * 100 / hostTotal); 300 RTPrintf("tstCollector: host cpu idle = %llu %%\n", (hostIdleStop - hostIdleStart) * 100 / hostTotal); 301 RTPrintf("tstCollector: process cpu user = %llu %%\n", (processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)); 302 RTPrintf("tstCollector: process cpu kernel = %llu %%\n\n", (processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)); 379 RTPrintf("tstCollector: host cpu user = %u.%u %%\n", 380 (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal), 381 (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100)); 382 RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n", 383 (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal), 384 (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100)); 385 RTPrintf("tstCollector: host cpu idle = %u.%u %%\n", 386 (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal), 387 (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100)); 388 RTPrintf("tstCollector: process cpu user = %u.%u %%\n", 389 (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)), 390 (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100)); 391 RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n", 392 (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)), 393 (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100)); 303 394 304 395 RTPrintf("tstCollector: TESTING - CPU load, looping for 5 sec\n"); … … 345 436 + hostKernelStop - hostKernelStart 346 437 + hostIdleStop - hostIdleStart; 347 RTPrintf("tstCollector: host cpu user = %llu %%\n", (hostUserStop - hostUserStart) * 100 / hostTotal); 348 RTPrintf("tstCollector: host cpu kernel = %llu %%\n", (hostKernelStop - hostKernelStart) * 100 / hostTotal); 349 RTPrintf("tstCollector: host cpu idle = %llu %%\n", (hostIdleStop - hostIdleStart) * 100 / hostTotal); 350 RTPrintf("tstCollector: process cpu user = %llu %%\n", (processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)); 351 RTPrintf("tstCollector: process cpu kernel = %llu %%\n\n", (processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)); 438 RTPrintf("tstCollector: host cpu user = %u.%u %%\n", 439 (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal), 440 (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100)); 441 RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n", 442 (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal), 443 (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100)); 444 RTPrintf("tstCollector: host cpu idle = %u.%u %%\n", 445 (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal), 446 (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100)); 447 RTPrintf("tstCollector: process cpu user = %u.%u %%\n", 448 (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)), 449 (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100)); 450 RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n", 451 (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)), 452 (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100)); 352 453 353 454 RTPrintf("tstCollector: TESTING - Memory usage\n"); … … 370 471 RTPrintf("tstCollector: host mem used = %lu kB\n", used); 371 472 RTPrintf("tstCollector: host mem available = %lu kB\n", available); 372 RTPrintf("tstCollector: process mem used = %lu kB\n ", processUsed);473 RTPrintf("tstCollector: process mem used = %lu kB\n\n", processUsed); 373 474 #endif 374 475 #if 1 375 476 rc = testNetwork(collector); 376 477 #endif 377 #if 0 378 RTPrintf("\ntstCollector: TESTING - Performance\n\n"); 478 #if 1 479 rc = testFsUsage(collector); 480 #endif 481 #if 1 482 rc = testDisk(collector); 483 #endif 484 #if 1 485 RTPrintf("tstCollector: TESTING - Performance\n\n"); 379 486 380 487 measurePerformance(collector, argv[0], 100);
Note:
See TracChangeset
for help on using the changeset viewer.