summaryrefslogtreecommitdiff
path: root/src/VBox/Main/testcase/tstCollector.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Main/testcase/tstCollector.cpp
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Main/testcase/tstCollector.cpp')
-rw-r--r--src/VBox/Main/testcase/tstCollector.cpp539
1 files changed, 307 insertions, 232 deletions
diff --git a/src/VBox/Main/testcase/tstCollector.cpp b/src/VBox/Main/testcase/tstCollector.cpp
index 1798d30e..63aaff4f 100644
--- a/src/VBox/Main/testcase/tstCollector.cpp
+++ b/src/VBox/Main/testcase/tstCollector.cpp
@@ -6,7 +6,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -63,7 +63,7 @@
if (RT_FAILURE(rc)) \
break; \
++nCalls; \
- } while(RTTimeMilliTS() - start < RUN_TIME_MS); \
+ } while (RTTimeMilliTS() - start < RUN_TIME_MS); \
if (RT_FAILURE(rc)) \
{ \
RTPrintf("tstCollector: "#fn" -> %Rrc\n", rc); \
@@ -152,8 +152,9 @@ int testNetwork(pm::CollectorHAL *collector)
uint64_t hostRxStart, hostTxStart;
uint64_t hostRxStop, hostTxStop, speed = 125000000; /* Assume 1Gbit/s */
- RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 sec...\n");
+ RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 s...\n");
+ hostRxStart = hostTxStart = 0;
int rc = collector->preCollect(hints, 0);
if (RT_FAILURE(rc))
{
@@ -161,36 +162,43 @@ int testNetwork(pm::CollectorHAL *collector)
return 1;
}
rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStart, &hostTxStart);
- if (RT_FAILURE(rc))
+ if (rc == VERR_NOT_IMPLEMENTED)
+ RTPrintf("tstCollector: getRawHostNetworkLoad() not implemented, skipping\n");
+ else
{
- RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
- return 1;
- }
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
+ return 1;
+ }
- RTThreadSleep(5000); // Sleep for five seconds
+ RTThreadSleep(5000); // Sleep for five seconds
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
- return 1;
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ hostRxStop = hostRxStart;
+ hostTxStop = hostTxStart;
+ rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n",
+ speed, speed/(1000000/8));
+ RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n",
+ (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8),
+ (hostRxStop - hostRxStart) * 100 / (speed * 5),
+ (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100);
+ RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n",
+ (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8),
+ (hostTxStop - hostTxStart) * 100 / (speed * 5),
+ (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100);
}
- RTPrintf("tstCollector: host network speed = %llu bytes/sec (%llu mbit/sec)\n",
- speed, speed/(1000000/8));
- RTPrintf("tstCollector: host network rx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n",
- (hostRxStop - hostRxStart)/5, (hostRxStop - hostRxStart)/(5000000/8),
- (hostRxStop - hostRxStart) * 100 / (speed * 5),
- (hostRxStop - hostRxStart) * 10000 / (speed * 5) % 100);
- RTPrintf("tstCollector: host network tx = %llu bytes/sec (%llu mbit/sec, %u.%u %%)\n\n",
- (hostTxStop - hostTxStart)/5, (hostTxStop - hostTxStart)/(5000000/8),
- (hostTxStop - hostTxStart) * 100 / (speed * 5),
- (hostTxStop - hostTxStart) * 10000 / (speed * 5) % 100);
return 0;
}
@@ -203,14 +211,19 @@ int testFsUsage(pm::CollectorHAL *collector)
ULONG total, used, available;
int rc = collector->getHostFilesystemUsage(FSNAME, &total, &used, &available);
- if (RT_FAILURE(rc))
+ if (rc == VERR_NOT_IMPLEMENTED)
+ RTPrintf("tstCollector: getHostFilesystemUsage() not implemented, skipping\n");
+ else
{
- RTPrintf("tstCollector: getHostFilesystemUsage() -> %Rrc\n", rc);
- return 1;
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getHostFilesystemUsage() -> %Rrc\n", rc);
+ return 1;
+ }
+ RTPrintf("tstCollector: host root fs total = %lu mB\n", total);
+ RTPrintf("tstCollector: host root fs used = %lu mB\n", used);
+ RTPrintf("tstCollector: host root fs available = %lu mB\n\n", available);
}
- RTPrintf("tstCollector: host root fs total = %lu mB\n", total);
- RTPrintf("tstCollector: host root fs used = %lu mB\n", used);
- RTPrintf("tstCollector: host root fs available = %lu mB\n\n", available);
return 0;
}
@@ -220,54 +233,82 @@ int testDisk(pm::CollectorHAL *collector)
uint64_t diskMsStart, totalMsStart;
uint64_t diskMsStop, totalMsStop;
- std::list<RTCString> disks;
- int rc = pm::getDiskListByFs(FSNAME, disks);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc);
- return 1;
- }
- if (disks.empty())
+ pm::DiskList disksUsage, disksLoad;
+ int rc = collector->getDiskListByFs(FSNAME, disksUsage, disksLoad);
+ if (rc == VERR_NOT_IMPLEMENTED)
+ RTPrintf("tstCollector: getDiskListByFs() not implemented, skipping\n");
+ else
{
- RTPrintf("tstCollector: getDiskListByFs(%s) returned empty list\n", FSNAME);
- return 1;
- }
-
- RTPrintf("tstCollector: TESTING - Disk utilization, sleeping for 5 sec...\n");
-
- hints.collectHostCpuLoad();
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostDiskLoad(disks.front().c_str(), &diskMsStart, &totalMsStart);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
- return 1;
- }
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getDiskListByFs(%s) -> %Rrc\n", FSNAME, rc);
+ return 1;
+ }
+ if (disksUsage.empty())
+ {
+ RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME);
+ return 1;
+ }
+ if (disksLoad.empty())
+ {
+ RTPrintf("tstCollector: getDiskListByFs(%s) returned empty usage list\n", FSNAME);
+ return 1;
+ }
- RTThreadSleep(5000); // Sleep for five seconds
+ pm::DiskList::iterator it;
+ for (it = disksUsage.begin(); it != disksUsage.end(); ++it)
+ {
+ uint64_t diskSize = 0;
+ rc = collector->getHostDiskSize(it->c_str(), &diskSize);
+ RTPrintf("tstCollector: TESTING - Disk size (%s) = %llu\n", it->c_str(), diskSize);
+ if (rc == VERR_FILE_NOT_FOUND)
+ RTPrintf("tstCollector: getHostDiskSize(%s) returned VERR_FILE_NOT_FOUND\n", it->c_str());
+ else if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getHostDiskSize() -> %Rrc\n", rc);
+ return 1;
+ }
+ }
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostDiskLoad(disks.front().c_str(), &diskMsStop, &totalMsStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostNetworkLoad() -> %Rrc\n", rc);
- return 1;
+ for (it = disksLoad.begin(); it != disksLoad.end(); ++it)
+ {
+ RTPrintf("tstCollector: TESTING - Disk utilization (%s), sleeping for 5 s...\n", it->c_str());
+
+ hints.collectHostCpuLoad();
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStart, &totalMsStart);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+
+ RTThreadSleep(5000); // Sleep for five seconds
+
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawHostDiskLoad(it->c_str(), &diskMsStop, &totalMsStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostDiskLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n",
+ (diskMsStop - diskMsStart),
+ (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)),
+ (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100),
+ totalMsStop - totalMsStart);
+ }
}
- RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n",
- (diskMsStop - diskMsStart),
- (unsigned)((diskMsStop - diskMsStart) * 100 / (totalMsStop - totalMsStart)),
- (unsigned)((diskMsStop - diskMsStart) * 10000 / (totalMsStop - totalMsStart) % 100),
- totalMsStop - totalMsStart);
return 0;
}
@@ -276,6 +317,8 @@ int testDisk(pm::CollectorHAL *collector)
int main(int argc, char *argv[])
{
+ bool cpuTest, ramTest, netTest, diskTest, fsTest, perfTest;
+ cpuTest = ramTest = netTest = diskTest = fsTest = perfTest = false;
/*
* Initialize the VBox runtime without loading
* the support driver.
@@ -286,12 +329,38 @@ int main(int argc, char *argv[])
RTPrintf("tstCollector: RTR3InitExe() -> %d\n", rc);
return 1;
}
- if (argc > 1 && !strcmp(argv[1], "-child"))
+ if (argc > 1)
{
- /* We have spawned ourselves as a child process -- scratch the leg */
- RTThreadSleep(1000000);
- return 1;
+ if (!strcmp(argv[1], "-child"))
+ {
+ /* We have spawned ourselves as a child process -- scratch the leg */
+ RTThreadSleep(1000000);
+ return 1;
+ }
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "-cpu"))
+ cpuTest = true;
+ else if (!strcmp(argv[i], "-ram"))
+ ramTest = true;
+ else if (!strcmp(argv[i], "-net"))
+ netTest = true;
+ else if (!strcmp(argv[i], "-disk"))
+ diskTest = true;
+ else if (!strcmp(argv[i], "-fs"))
+ fsTest = true;
+ else if (!strcmp(argv[i], "-perf"))
+ perfTest = true;
+ else
+ {
+ RTPrintf("tstCollector: Unknown option: %s\n", argv[i]);
+ return 2;
+ }
+ }
}
+ else
+ cpuTest = ramTest = netTest = diskTest = fsTest = perfTest = true;
+
#ifdef RT_OS_WINDOWS
HRESULT hRes = CoInitialize(NULL);
/*
@@ -313,12 +382,18 @@ int main(int argc, char *argv[])
RTPrintf("tstCollector: createMetricFactory() failed\n", rc);
return 1;
}
-#if 1
+
pm::CollectorHints hints;
- hints.collectHostCpuLoad();
- hints.collectHostRamUsage();
- hints.collectProcessCpuLoad(RTProcSelf());
- hints.collectProcessRamUsage(RTProcSelf());
+ if (cpuTest)
+ {
+ hints.collectHostCpuLoad();
+ hints.collectProcessCpuLoad(RTProcSelf());
+ }
+ if (ramTest)
+ {
+ hints.collectHostRamUsage();
+ hints.collectProcessRamUsage(RTProcSelf());
+ }
uint64_t start;
@@ -328,164 +403,164 @@ int main(int argc, char *argv[])
uint64_t processUserStart, processKernelStart, processTotalStart;
uint64_t processUserStop, processKernelStop, processTotalStop;
- RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 sec\n");
-
rc = collector->preCollect(hints, 0);
if (RT_FAILURE(rc))
{
RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
return 1;
}
- rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
- if (RT_FAILURE(rc))
+ if (cpuTest)
{
- RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
+ RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 s...\n");
+
+ rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
- RTThreadSleep(5000); // Sleep for 5 seconds
+ RTThreadSleep(5000); // Sleep for 5 seconds
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- hostTotal = hostUserStop - hostUserStart
- + hostKernelStop - hostKernelStart
- + hostIdleStop - hostIdleStart;
- /*printf("tstCollector: host cpu user = %f sec\n", (hostUserStop - hostUserStart) / 10000000.);
- printf("tstCollector: host cpu kernel = %f sec\n", (hostKernelStop - hostKernelStart) / 10000000.);
- printf("tstCollector: host cpu idle = %f sec\n", (hostIdleStop - hostIdleStart) / 10000000.);
- printf("tstCollector: host cpu total = %f sec\n", hostTotal / 10000000.);*/
- RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
- (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
- (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
- (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
- (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
- (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
- (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
- (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
- (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
- RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
- (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
- (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
-
- RTPrintf("tstCollector: TESTING - CPU load, looping for 5 sec\n");
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- start = RTTimeMilliTS();
- while(RTTimeMilliTS() - start < 5000)
- ; // Loop for 5 seconds
- rc = collector->preCollect(hints, 0);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
- return 1;
- }
- hostTotal = hostUserStop - hostUserStart
- + hostKernelStop - hostKernelStart
- + hostIdleStop - hostIdleStart;
- RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
- (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
- (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
- (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
- (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
- (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
- (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
- RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
- (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
- (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
- RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
- (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
- (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
-
- RTPrintf("tstCollector: TESTING - Memory usage\n");
-
- ULONG total, used, available, processUsed;
-
- rc = collector->getHostMemoryUsage(&total, &used, &available);
- if (RT_FAILURE(rc))
- {
- RTPrintf("tstCollector: getHostMemoryUsage() -> %Rrc\n", rc);
- return 1;
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ hostTotal = hostUserStop - hostUserStart
+ + hostKernelStop - hostKernelStart
+ + hostIdleStop - hostIdleStart;
+ RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
+ (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
+ (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
+ (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
+ (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
+ (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
+ (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
+ (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
+ (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
+ RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
+ (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
+ (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
+
+ RTPrintf("tstCollector: TESTING - CPU load, looping for 5 s...\n");
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawHostCpuLoad(&hostUserStart, &hostKernelStart, &hostIdleStart);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ start = RTTimeMilliTS();
+ while (RTTimeMilliTS() - start < 5000)
+ ; // Loop for 5 seconds
+ rc = collector->preCollect(hints, 0);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: preCollect() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawHostCpuLoad(&hostUserStop, &hostKernelStop, &hostIdleStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawHostCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getRawProcessCpuLoad() -> %Rrc\n", rc);
+ return 1;
+ }
+ hostTotal = hostUserStop - hostUserStart
+ + hostKernelStop - hostKernelStart
+ + hostIdleStop - hostIdleStart;
+ RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
+ (unsigned)((hostUserStop - hostUserStart) * 100 / hostTotal),
+ (unsigned)((hostUserStop - hostUserStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
+ (unsigned)((hostKernelStop - hostKernelStart) * 100 / hostTotal),
+ (unsigned)((hostKernelStop - hostKernelStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
+ (unsigned)((hostIdleStop - hostIdleStart) * 100 / hostTotal),
+ (unsigned)((hostIdleStop - hostIdleStart) * 10000 / hostTotal % 100));
+ RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
+ (unsigned)((processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart)),
+ (unsigned)((processUserStop - processUserStart) * 10000 / (processTotalStop - processTotalStart) % 100));
+ RTPrintf("tstCollector: process cpu kernel = %u.%u %%\n\n",
+ (unsigned)((processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart)),
+ (unsigned)((processKernelStop - processKernelStart) * 10000 / (processTotalStop - processTotalStart) % 100));
}
- rc = collector->getProcessMemoryUsage(RTProcSelf(), &processUsed);
- if (RT_FAILURE(rc))
+
+ if (ramTest)
{
- RTPrintf("tstCollector: getProcessMemoryUsage() -> %Rrc\n", rc);
- return 1;
+ RTPrintf("tstCollector: TESTING - Memory usage\n");
+
+ ULONG total, used, available, processUsed;
+
+ rc = collector->getHostMemoryUsage(&total, &used, &available);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getHostMemoryUsage() -> %Rrc\n", rc);
+ return 1;
+ }
+ rc = collector->getProcessMemoryUsage(RTProcSelf(), &processUsed);
+ if (RT_FAILURE(rc))
+ {
+ RTPrintf("tstCollector: getProcessMemoryUsage() -> %Rrc\n", rc);
+ return 1;
+ }
+ RTPrintf("tstCollector: host mem total = %lu kB\n", total);
+ RTPrintf("tstCollector: host mem used = %lu kB\n", used);
+ RTPrintf("tstCollector: host mem available = %lu kB\n", available);
+ RTPrintf("tstCollector: process mem used = %lu kB\n\n", processUsed);
}
- RTPrintf("tstCollector: host mem total = %lu kB\n", total);
- RTPrintf("tstCollector: host mem used = %lu kB\n", used);
- RTPrintf("tstCollector: host mem available = %lu kB\n", available);
- RTPrintf("tstCollector: process mem used = %lu kB\n\n", processUsed);
-#endif
-#if 1
- rc = testNetwork(collector);
-#endif
-#if 1
+
+ if (netTest)
+ rc = testNetwork(collector);
+ if (fsTest)
rc = testFsUsage(collector);
-#endif
-#if 1
- rc = testDisk(collector);
-#endif
-#if 1
- RTPrintf("tstCollector: TESTING - Performance\n\n");
+ if (diskTest)
+ rc = testDisk(collector);
+ if (perfTest)
+ {
+ RTPrintf("tstCollector: TESTING - Performance\n\n");
- measurePerformance(collector, argv[0], 100);
-#endif
+ measurePerformance(collector, argv[0], 100);
+ }
delete collector;