VirtualBox

source: vbox/trunk/src/VBox/Main/testcase/tstCollector.cpp@ 107866

Last change on this file since 107866 was 107560, checked in by vboxsync, 5 weeks ago

src/VBox/Main/testcase/tstCollector.cpp: Fixed warnings found by Parfait (assignment unused). Lots of renaming, needs further cleanup. jiraref:VBP-1424

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.6 KB
Line 
1/* $Id: tstCollector.cpp 107560 2025-01-09 08:56:01Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Performance collector classes test cases.
4 */
5
6/*
7 * Copyright (C) 2008-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifdef RT_OS_DARWIN
29# include "../src-server/darwin/PerformanceDarwin.cpp"
30#endif
31#ifdef RT_OS_FREEBSD
32# include "../src-server/freebsd/PerformanceFreeBSD.cpp"
33#endif
34#ifdef RT_OS_LINUX
35# include "../src-server/linux/PerformanceLinux.cpp"
36#endif
37#ifdef RT_OS_OS2
38# include "../src-server/os2/PerformanceOS2.cpp"
39#endif
40#ifdef RT_OS_SOLARIS
41# include "../src-server/solaris/PerformanceSolaris.cpp"
42#endif
43#ifdef RT_OS_WINDOWS
44# define _WIN32_DCOM
45# include <iprt/win/objidl.h>
46# include <iprt/win/objbase.h>
47# include "../src-server/win/PerformanceWin.cpp"
48#endif
49
50#include <iprt/initterm.h>
51#include <iprt/stream.h>
52#include <iprt/env.h>
53#include <iprt/err.h>
54#include <iprt/process.h>
55#include <iprt/thread.h>
56#include <iprt/time.h>
57
58#define RUN_TIME_MS 1000
59
60#define N_CALLS(n, fn) \
61 do {\
62 for (int call = 0; call < n; ++call) \
63 rc = collector->fn; \
64 if (RT_FAILURE(rc)) \
65 RTPrintf("tstCollector: "#fn" -> %Rrc\n", rc); \
66 } while (0)
67
68#define CALLS_PER_SECOND(fn, args) \
69 do { \
70 nCalls = 0; \
71 start = RTTimeMilliTS(); \
72 do { \
73 rc = collector->fn args; \
74 if (RT_FAILURE(rc)) \
75 break; \
76 ++nCalls; \
77 } while (RTTimeMilliTS() - start < RUN_TIME_MS); \
78 if (RT_FAILURE(rc)) \
79 RTPrintf("tstCollector: "#fn" -> %Rrc\n", rc); \
80 else \
81 RTPrintf("%70s -- %u calls per second\n", #fn, nCalls); \
82 } while (0)
83
84static void shutdownProcessList(std::vector<RTPROCESS> const &rProcesses)
85{
86 for (size_t i = 0; i < rProcesses.size(); i++)
87 RTProcTerminate(rProcesses[i]);
88}
89
90static void measurePerformance(pm::CollectorHAL *collector, const char *pszName, int cVMs)
91{
92
93 const char * const args[] = { pszName, "-child", NULL };
94 pm::CollectorHints hints;
95 std::vector<RTPROCESS> processes;
96
97 hints.collectHostCpuLoad();
98 hints.collectHostRamUsage();
99 /* Start fake VMs */
100 for (int i = 0; i < cVMs; ++i)
101 {
102 RTPROCESS pid;
103 int rc = RTProcCreate(pszName, args, RTENV_DEFAULT, 0, &pid);
104 if (RT_FAILURE(rc))
105 {
106 hints.getProcesses(processes);
107 shutdownProcessList(processes);
108
109 RTPrintf("tstCollector: RTProcCreate() -> %Rrc\n", rc);
110 return;
111 }
112 hints.collectProcessCpuLoad(pid);
113 hints.collectProcessRamUsage(pid);
114 }
115
116 hints.getProcesses(processes);
117 RTThreadSleep(30000); // Let children settle for half a minute
118
119 int rc;
120 ULONG tmp;
121 uint64_t tmp64;
122 uint64_t start;
123 unsigned int nCalls;
124 /* Pre-collect */
125 CALLS_PER_SECOND(preCollect, (hints, 0));
126 /* Host CPU load */
127 CALLS_PER_SECOND(getRawHostCpuLoad, (&tmp64, &tmp64, &tmp64));
128 /* Process CPU load */
129 CALLS_PER_SECOND(getRawProcessCpuLoad, (processes[nCalls % cVMs], &tmp64, &tmp64, &tmp64));
130 /* Host CPU speed */
131 CALLS_PER_SECOND(getHostCpuMHz, (&tmp));
132 /* Host RAM usage */
133 CALLS_PER_SECOND(getHostMemoryUsage, (&tmp, &tmp, &tmp));
134 /* Process RAM usage */
135 CALLS_PER_SECOND(getProcessMemoryUsage, (processes[nCalls % cVMs], &tmp));
136
137 start = RTTimeNanoTS();
138
139 int times;
140 for (times = 0; times < 100; times++)
141 {
142 /* Pre-collect */
143 N_CALLS(1, preCollect(hints, 0));
144 /* Host CPU load */
145 N_CALLS(1, getRawHostCpuLoad(&tmp64, &tmp64, &tmp64));
146 /* Host CPU speed */
147 N_CALLS(1, getHostCpuMHz(&tmp));
148 /* Host RAM usage */
149 N_CALLS(1, getHostMemoryUsage(&tmp, &tmp, &tmp));
150 /* Process CPU load */
151 N_CALLS(cVMs, getRawProcessCpuLoad(processes[call], &tmp64, &tmp64, &tmp64));
152 /* Process RAM usage */
153 N_CALLS(cVMs, getProcessMemoryUsage(processes[call], &tmp));
154 }
155 RTPrintf("\n%d VMs -- %u%% of CPU time\n", cVMs, (unsigned)((double)(RTTimeNanoTS() - start) / 10000000.0 / times));
156
157 /* Shut down fake VMs */
158 shutdownProcessList(processes);
159}
160
161#ifdef RT_OS_SOLARIS
162#define NETIFNAME "net0"
163#else
164#define NETIFNAME "eth0"
165#endif
166static int testNetwork(pm::CollectorHAL *collector)
167{
168 pm::CollectorHints hints;
169 uint64_t hostRxStart, hostTxStart;
170 uint64_t hostRxStop, hostTxStop, speed = 125000000; /* Assume 1Gbit/s */
171
172 RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 s...\n");
173
174 hostRxStart = hostTxStart = 0;
175 int rc = collector->preCollect(hints, 0);
176 if (RT_FAILURE(rc))
177 {
178 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
179 return rc;
180 }
181 rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStart, &hostTxStart);
182 if (rc == VERR_NOT_IMPLEMENTED)
183 RTPrintf("tstCollector: getRawHostNetworkLoad() not implemented, skipping\n");
184 else
185 {
186 if (RT_FAILURE(rc))
187 {
188 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
189 return rc;
190 }
191
192 RTThreadSleep(5000); // Sleep for five seconds
193
194 rc = collector->preCollect(hints, 0);
195 if (RT_FAILURE(rc))
196 {
197 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
198 return rc;
199 }
200 hostRxStop = hostRxStart;
201 hostTxStop = hostTxStart;
202 rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop);
203 if (RT_FAILURE(rc))
204 {
205 RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
206 return rc;
207 }
208 RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n",
209 speed, speed/(1000000/8));
210 RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n",
211 (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8),
212 (hostRxStop - hostRxStart) * 100 / (speed * 5),
213 (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100);
214 RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n",
215 (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8),
216 (hostTxStop - hostTxStart) * 100 / (speed * 5),
217 (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100);
218 }
219
220 return rc;
221}
222
223#define FSNAME "/"
224static int testFsUsage(pm::CollectorHAL *collector)
225{
226 RTPrintf("tstCollector: TESTING - File system usage\n");
227
228 ULONG total, used, available;
229
230 int rc = collector->getHostFilesystemUsage(FSNAME, &total, &used, &available);
231 if (rc == VERR_NOT_IMPLEMENTED)
232 RTPrintf("tstCollector: getHostFilesystemUsage() not implemented, skipping\n");
233 else
234 {
235 if (RT_FAILURE(rc))
236 {
237 RTPrintf("tstCollector: getHostFilesystemUsage() -> %Rrc\n", rc);
238 return rc;
239 }
240 RTPrintf("tstCollector: host root fs total = %lu MB\n", total);
241 RTPrintf("tstCollector: host root fs used = %lu MB\n", used);
242 RTPrintf("tstCollector: host root fs available = %lu MB\n\n", available);
243 }
244 return rc;
245}
246
247static int testDisk(pm::CollectorHAL *collector)
248{
249 pm::CollectorHints hints;
250 uint64_t diskMsStart, totalMsStart;
251 uint64_t diskMsStop, totalMsStop;
252
253 pm::DiskList disksUsage, disksLoad;
254 int rc = collector->getDiskListByFs(FSNAME, disksUsage, disksLoad);
255 if (rc == VERR_NOT_IMPLEMENTED)
256 RTPrintf("tstCollector: getDiskListByFs() not implemented, skipping\n");
257 else
258 {
259 if (RT_FAILURE(rc))
260 {
261 RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc);
262 return rc;
263 }
264 if (disksUsage.empty())
265 {
266 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME);
267 return VINF_SUCCESS;
268 }
269 if (disksLoad.empty())
270 {
271 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME);
272 return VINF_SUCCESS;
273 }
274
275 pm::DiskList::iterator it;
276 for (it = disksUsage.begin(); it != disksUsage.end(); ++it)
277 {
278 uint64_t diskSize = 0;
279 rc = collector->getHostDiskSize(it->c_str(), &diskSize);
280 RTPrintf("tstCollector: TESTING - Disk size (%s) = %llu\n", it->c_str(), diskSize);
281 if (rc == VERR_FILE_NOT_FOUND)
282 RTPrintf("tstCollector: getHostDiskSize(%s) returned VERR_FILE_NOT_FOUND\n", it->c_str());
283 else if (RT_FAILURE(rc))
284 {
285 RTPrintf("tstCollector: getHostDiskSize() -> %Rrc\n", rc);
286 return rc;
287 }
288 }
289
290 for (it = disksLoad.begin(); it != disksLoad.end(); ++it)
291 {
292 RTPrintf("tstCollector: TESTING - Disk utilization (%s), sleeping for 5 s...\n", it->c_str());
293
294 hints.collectHostCpuLoad();
295 rc = collector->preCollect(hints, 0);
296 if (RT_FAILURE(rc))
297 {
298 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
299 return rc;
300 }
301 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStart, &totalMsStart);
302 if (RT_FAILURE(rc))
303 {
304 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc);
305 return rc;
306 }
307
308 RTThreadSleep(5000); // Sleep for five seconds
309
310 rc = collector->preCollect(hints, 0);
311 if (RT_FAILURE(rc))
312 {
313 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
314 return rc;
315 }
316 rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStop, &totalMsStop);
317 if (RT_FAILURE(rc))
318 {
319 RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc);
320 return rc;
321 }
322 RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n",
323 (diskMsStop - diskMsStart),
324 (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)),
325 (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100),
326 totalMsStop - totalMsStart);
327 }
328 }
329
330 return VINF_SUCCESS;
331}
332
333
334
335int main(int argc, char *argv[])
336{
337 /*
338 * Initialize the VBox runtime without loading
339 * the support driver.
340 */
341 int rc = RTR3InitExe(argc, &argv, 0);
342 if (RT_FAILURE(rc))
343 {
344 RTPrintf("tstCollector: RTR3InitExe() -> %Rrc\n", rc);
345 return RTEXITCODE_FAILURE;
346 }
347
348 bool cpuTest, ramTest, netTest, diskTest, fsTest, perfTest;
349
350 cpuTest = ramTest = netTest = diskTest = fsTest = perfTest = false;
351
352 if (argc > 1)
353 {
354 if (!strcmp(argv[1], "-child"))
355 {
356 /* We have spawned ourselves as a child process -- scratch the leg */
357 RTThreadSleep(1000000);
358 return 1;
359 }
360 for (int i = 1; i < argc; i++)
361 {
362 if (!strcmp(argv[i], "-cpu"))
363 cpuTest = true;
364 else if (!strcmp(argv[i], "-ram"))
365 ramTest = true;
366 else if (!strcmp(argv[i], "-net"))
367 netTest = true;
368 else if (!strcmp(argv[i], "-disk"))
369 diskTest = true;
370 else if (!strcmp(argv[i], "-fs"))
371 fsTest = true;
372 else if (!strcmp(argv[i], "-perf"))
373 perfTest = true;
374 else
375 {
376 RTPrintf("tstCollector: Unknown option: %s\n", argv[i]);
377 return RTEXITCODE_SYNTAX;
378 }
379 }
380 }
381 else
382 cpuTest = ramTest = netTest = diskTest = fsTest = perfTest = true;
383
384#ifdef RT_OS_WINDOWS
385 HRESULT hRes = CoInitialize(NULL);
386 /*
387 * Need to initialize security to access performance enumerators.
388 */
389 hRes = CoInitializeSecurity(
390 NULL,
391 -1,
392 NULL,
393 NULL,
394 RPC_C_AUTHN_LEVEL_NONE,
395 RPC_C_IMP_LEVEL_IMPERSONATE,
396 NULL, EOAC_NONE, 0);
397#endif
398
399 pm::CollectorHAL *collector = pm::createHAL();
400 if (!collector)
401 {
402 RTPrintf("tstCollector: createMetricFactory() failed\n");
403 return RTEXITCODE_FAILURE;
404 }
405
406 pm::CollectorHints hints;
407 if (cpuTest)
408 {
409 hints.collectHostCpuLoad();
410 hints.collectProcessCpuLoad(RTProcSelf());
411 }
412 if (ramTest)
413 {
414 hints.collectHostRamUsage();
415 hints.collectProcessRamUsage(RTProcSelf());
416 }
417
418 uint64_t start;
419
420 uint64_t hostUserStart, hostKernelStart, hostIdleStart;
421 uint64_t hostUserStop, hostKernelStop, hostIdleStop, hostTotal;
422
423 uint64_t processUserStart, processKernelStart, processTotalStart;
424 uint64_t processUserStop, processKernelStop, processTotalStop;
425
426 rc = collector->preCollect(hints, 0);
427 if (RT_FAILURE(rc))
428 {
429 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
430 return RTEXITCODE_FAILURE;
431 }
432 if (cpuTest)
433 {
434 RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 s...\n");
435
436 rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
437 if (RT_FAILURE(rc))
438 {
439 RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
440 return RTEXITCODE_FAILURE;
441 }
442 rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
443 if (RT_FAILURE(rc))
444 {
445 RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
446 return RTEXITCODE_FAILURE;
447 }
448
449 RTThreadSleep(5000); // Sleep for 5 seconds
450
451 rc = collector->preCollect(hints, 0);
452 if (RT_FAILURE(rc))
453 {
454 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
455 return RTEXITCODE_FAILURE;
456 }
457 rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
458 if (RT_FAILURE(rc))
459 {
460 RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
461 return RTEXITCODE_FAILURE;
462 }
463 rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
464 if (RT_FAILURE(rc))
465 {
466 RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
467 return RTEXITCODE_FAILURE;
468 }
469 hostTotal = hostUserStop - hostUserStart
470 + hostKernelStop - hostKernelStart
471 + hostIdleStop - hostIdleStart;
472 RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
473 (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
474 (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
475 RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
476 (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
477 (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
478 RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
479 (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
480 (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
481 RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
482 (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
483 (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
484 RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
485 (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
486 (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
487
488 RTPrintf("tstCollector: TESTING - CPU load, looping for 5 s...\n");
489 rc = collector->preCollect(hints, 0);
490 if (RT_FAILURE(rc))
491 {
492 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
493 return RTEXITCODE_FAILURE;
494 }
495 rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
496 if (RT_FAILURE(rc))
497 {
498 RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
499 return RTEXITCODE_FAILURE;
500 }
501 rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
502 if (RT_FAILURE(rc))
503 {
504 RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
505 return RTEXITCODE_FAILURE;
506 }
507 start = RTTimeMilliTS();
508 while (RTTimeMilliTS() - start < 5000)
509 ; // Loop for 5 seconds
510 rc = collector->preCollect(hints, 0);
511 if (RT_FAILURE(rc))
512 {
513 RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
514 return RTEXITCODE_FAILURE;
515 }
516 rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
517 if (RT_FAILURE(rc))
518 {
519 RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
520 return RTEXITCODE_FAILURE;
521 }
522 rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
523 if (RT_FAILURE(rc))
524 {
525 RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
526 return RTEXITCODE_FAILURE;
527 }
528 hostTotal = hostUserStop - hostUserStart
529 + hostKernelStop - hostKernelStart
530 + hostIdleStop - hostIdleStart;
531 RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
532 (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
533 (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
534 RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
535 (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
536 (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
537 RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
538 (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
539 (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
540 RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
541 (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
542 (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
543 RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
544 (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
545 (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
546 }
547
548 if (ramTest)
549 {
550 RTPrintf("tstCollector: TESTING - Memory usage\n");
551
552 ULONG total, used, available, processUsed;
553
554 rc = collector->getHostMemoryUsage(&total, &used, &available);
555 if (RT_FAILURE(rc))
556 {
557 RTPrintf("tstCollector: getHostMemoryUsage() -> %Rrc\n", rc);
558 return RTEXITCODE_FAILURE;
559 }
560
561 rc = collector->getProcessMemoryUsage(RTProcSelf(), &processUsed);
562 if (RT_FAILURE(rc))
563 {
564 RTPrintf("tstCollector: getProcessMemoryUsage() -> %Rrc\n", rc);
565 return RTEXITCODE_FAILURE;
566 }
567
568 RTPrintf("tstCollector: host mem total = %lu kB\n", total);
569 RTPrintf("tstCollector: host mem used = %lu kB\n", used);
570 RTPrintf("tstCollector: host mem available = %lu kB\n", available);
571 RTPrintf("tstCollector: process mem used = %lu kB\n\n", processUsed);
572 }
573
574 if (netTest)
575 testNetwork(collector);
576 if (fsTest)
577 testFsUsage(collector);
578 if (diskTest)
579 testDisk(collector);
580
581 if (perfTest)
582 {
583 RTPrintf("tstCollector: TESTING - Performance\n\n");
584 measurePerformance(collector, argv[0], 100);
585 }
586
587 delete collector;
588
589 RTPrintf("\ntstCollector FINISHED.\n");
590
591 return RTEXITCODE_SUCCESS;
592}
593
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette