tstCollector.cpp revision 0ff7152ccdcc57edca12c5f17b9699c66eeff975
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* $Id$ */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/** @file
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Collector classes test cases.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Copyright (C) 2008 Sun Microsystems, Inc.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * available from http://www.virtualbox.org. This file is free software;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * General Public License (GPL) as published by the Free Software
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * additional information or have any questions.
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync */
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#include <iprt/runtime.h>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#include <iprt/stream.h>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#include <iprt/env.h>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#include <iprt/err.h>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#include <iprt/process.h>
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_SOLARIS
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include "../solaris/PerformanceSolaris.cpp"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_LINUX
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include "../linux/PerformanceLinux.cpp"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_WINDOWS
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define _WIN32_DCOM
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <objidl.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include <objbase.h>
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include "../win/PerformanceWin.cpp"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_OS2
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include "../os2/PerformanceOS2.cpp"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_DARWIN
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#include "../darwin/PerformanceDarwin.cpp"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define RUN_TIME_MS 1000
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define N_CALLS(n, fn) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for (int call = 0; call < n; ++call) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync rc = collector->fn; \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (RT_FAILURE(rc)) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: "#fn" -> %Rrc\n", rc)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define CALLS_PER_SECOND(fn) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync nCalls = 0; \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync start = RTTimeMilliTS(); \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync do { \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync rc = collector->fn; \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (RT_FAILURE(rc)) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync break; \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ++nCalls; \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } while(RTTimeMilliTS() - start < RUN_TIME_MS); \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (RT_FAILURE(rc)) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync { \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: "#fn" -> %Rrc\n", rc); \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync else \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("%70s -- %u calls per second\n", #fn, nCalls)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncvoid measurePerformance(pm::CollectorHAL *collector, const char *pszName, int cVMs)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync{
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync static const char * const args[] = { pszName, "-child", NULL };
a180a41bba1d50822df23fff0099e90b86638b89vboxsync pm::CollectorHints hints;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync std::vector<RTPROCESS> processes;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectHostCpuLoad();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectHostRamUsage();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Start fake VMs */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for (int i = 0; i < cVMs; ++i)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPROCESS pid;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int rc = RTProcCreate(pszName, args, RTENV_DEFAULT, 0, &pid);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (RT_FAILURE(rc))
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.getProcesses(processes);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync std::for_each(processes.begin(), processes.end(), std::ptr_fun(RTProcTerminate));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: RTProcCreate() -> %Rrc\n", rc);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectProcessCpuLoad(pid);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectProcessRamUsage(pid);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.getProcesses(processes);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTThreadSleep(30000); // Let children settle for half a minute
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int rc;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ULONG tmp;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t tmp64;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unsigned int nCalls;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Pre-collect */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(preCollect(hints));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host CPU load */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(getRawHostCpuLoad(&tmp64, &tmp64, &tmp64));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Process CPU load */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(getRawProcessCpuLoad(processes[nCalls%cVMs], &tmp64, &tmp64, &tmp64));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host CPU speed */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(getHostCpuMHz(&tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host RAM usage */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(getHostMemoryUsage(&tmp, &tmp, &tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Process RAM usage */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync CALLS_PER_SECOND(getProcessMemoryUsage(processes[nCalls%cVMs], &tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync start = RTTimeNanoTS();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int times;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync for (times = 0; times < 100; times++)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Pre-collect */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(1, preCollect(hints));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host CPU load */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(1, getRawHostCpuLoad(&tmp64, &tmp64, &tmp64));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host CPU speed */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(1, getHostCpuMHz(&tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Host RAM usage */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(1, getHostMemoryUsage(&tmp, &tmp, &tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Process CPU load */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(cVMs, getRawProcessCpuLoad(processes[call], &tmp64, &tmp64, &tmp64));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Process RAM usage */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync N_CALLS(cVMs, getProcessMemoryUsage(processes[call], &tmp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("\n%u VMs -- %.2f%% of CPU time\n", cVMs, (RTTimeNanoTS() - start) / 10000000. / times);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Shut down fake VMs */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync std::for_each(processes.begin(), processes.end(), std::ptr_fun(RTProcTerminate));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync}
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncint main(int argc, char *argv[])
a180a41bba1d50822df23fff0099e90b86638b89vboxsync{
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Initialize the VBox runtime without loading
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the support driver.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int rc = RTR3Init();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (RT_FAILURE(rc))
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: RTR3Init() -> %d\n", rc);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (argc > 1 && !strcmp(argv[1], "-child"))
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* We have spawned ourselves as a child process -- scratch the leg */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTThreadSleep(1000000);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#ifdef RT_OS_WINDOWS
a180a41bba1d50822df23fff0099e90b86638b89vboxsync HRESULT hRes = CoInitialize(NULL);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /*
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Need to initialize security to access performance enumerators.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hRes = CoInitializeSecurity(
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NULL,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync -1,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NULL,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NULL,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RPC_C_AUTHN_LEVEL_NONE,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RPC_C_IMP_LEVEL_IMPERSONATE,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync NULL, EOAC_NONE, 0);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync pm::CollectorHAL *collector = pm::createHAL();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if (!collector)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: createMetricFactory() failed\n", rc);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return 1;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#if 1
a180a41bba1d50822df23fff0099e90b86638b89vboxsync pm::CollectorHints hints;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectHostCpuLoad();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectHostRamUsage();
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectProcessCpuLoad(RTProcSelf());
a180a41bba1d50822df23fff0099e90b86638b89vboxsync hints.collectProcessRamUsage(RTProcSelf());
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t start;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t hostUserStart, hostKernelStart, hostIdleStart;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t hostUserStop, hostKernelStop, hostIdleStop, hostTotal;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t processUserStart, processKernelStart, processTotalStart;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync uint64_t processUserStop, processKernelStop, processTotalStop;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync
a180a41bba1d50822df23fff0099e90b86638b89vboxsync RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 sec\n");
rc = collector->preCollect(hints);
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;
}
RTThreadSleep(5000); // Sleep for 5 seconds
rc = collector->preCollect(hints);
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 = %llu %%\n", (hostUserStop - hostUserStart) * 100 / hostTotal);
RTPrintf("tstCollector: host cpu kernel = %llu %%\n", (hostKernelStop - hostKernelStart) * 100 / hostTotal);
RTPrintf("tstCollector: host cpu idle = %llu %%\n", (hostIdleStop - hostIdleStart) * 100 / hostTotal);
RTPrintf("tstCollector: process cpu user = %llu %%\n", (processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart));
RTPrintf("tstCollector: process cpu kernel = %llu %%\n\n", (processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart));
RTPrintf("tstCollector: TESTING - CPU load, looping for 5 sec\n");
rc = collector->preCollect(hints);
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);
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 = %llu %%\n", (hostUserStop - hostUserStart) * 100 / hostTotal);
RTPrintf("tstCollector: host cpu kernel = %llu %%\n", (hostKernelStop - hostKernelStart) * 100 / hostTotal);
RTPrintf("tstCollector: host cpu idle = %llu %%\n", (hostIdleStop - hostIdleStart) * 100 / hostTotal);
RTPrintf("tstCollector: process cpu user = %llu %%\n", (processUserStop - processUserStart) * 100 / (processTotalStop - processTotalStart));
RTPrintf("tstCollector: process cpu kernel = %llu %%\n\n", (processKernelStop - processKernelStart) * 100 / (processTotalStop - processTotalStart));
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", processUsed);
#endif
RTPrintf("\ntstCollector: TESTING - Performance\n\n");
measurePerformance(collector, argv[0], 100);
delete collector;
printf ("\ntstCollector FINISHED.\n");
return rc;
}