tstCollector.cpp revision 6f4550210b018b6a25af5bd11fddabb14b69ff60
/* $Id$ */
/** @file
*
* Collector classes test cases.
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifdef RT_OS_DARWIN
# include "../src-server/darwin/PerformanceDarwin.cpp"
#endif
#ifdef RT_OS_FREEBSD
# include "../src-server/freebsd/PerformanceFreeBSD.cpp"
#endif
#ifdef RT_OS_LINUX
# include "../src-server/linux/PerformanceLinux.cpp"
#endif
#ifdef RT_OS_OS2
# include "../src-server/os2/PerformanceOS2.cpp"
#endif
#ifdef RT_OS_SOLARIS
# include "../src-server/solaris/PerformanceSolaris.cpp"
#endif
#ifdef RT_OS_WINDOWS
# define _WIN32_DCOM
# include <objidl.h>
# include <objbase.h>
# include "../src-server/win/PerformanceWin.cpp"
#endif
#include <iprt/initterm.h>
#define RUN_TIME_MS 1000
if (RT_FAILURE(rc)) \
#define CALLS_PER_SECOND(fn) \
nCalls = 0; \
start = RTTimeMilliTS(); \
do { \
if (RT_FAILURE(rc)) \
break; \
++nCalls; \
if (RT_FAILURE(rc)) \
{ \
} \
else \
{
/* Start fake VMs */
for (int i = 0; i < cVMs; ++i)
{
if (RT_FAILURE(rc))
{
return;
}
}
int rc;
unsigned int nCalls;
/* Pre-collect */
/* Host CPU load */
/* Process CPU load */
/* Host CPU speed */
/* Host RAM usage */
/* Process RAM usage */
start = RTTimeNanoTS();
int times;
{
/* Pre-collect */
/* Host CPU load */
/* Host CPU speed */
/* Host RAM usage */
/* Process CPU load */
/* Process RAM usage */
}
/* Shut down fake VMs */
}
#ifdef RT_OS_SOLARIS
#define NETIFNAME "net0"
#else
#define NETIFNAME "eth0"
#endif
{
RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 sec...\n");
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
return 0;
}
#define FSNAME "/"
{
RTPrintf("tstCollector: TESTING - File system usage\n");
if (RT_FAILURE(rc))
{
return 1;
}
return 0;
}
{
if (RT_FAILURE(rc))
{
return 1;
}
{
return 1;
}
RTPrintf("tstCollector: TESTING - Disk utilization (%s), sleeping for 5 sec...\n", disks.front().c_str());
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
RTPrintf("tstCollector: host disk util = %llu msec (%u.%u %%), total = %llu msec\n\n",
(diskMsStop - diskMsStart),
return 0;
}
{
/*
* Initialize the VBox runtime without loading
* the support driver.
*/
if (RT_FAILURE(rc))
{
return 1;
}
{
/* We have spawned ourselves as a child process -- scratch the leg */
RTThreadSleep(1000000);
return 1;
}
#ifdef RT_OS_WINDOWS
/*
* Need to initialize security to access performance enumerators.
*/
NULL,
-1,
NULL,
NULL,
#endif
if (!collector)
{
return 1;
}
#if 1
RTPrintf("tstCollector: TESTING - CPU load, sleeping for 5 sec\n");
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
if (RT_FAILURE(rc))
{
return 1;
}
/*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",
RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
(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");
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStart, &processKernelStart, &processTotalStart);
if (RT_FAILURE(rc))
{
return 1;
}
start = RTTimeMilliTS();
; // Loop for 5 seconds
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
rc = collector->getRawProcessCpuLoad(RTProcSelf(), &processUserStop, &processKernelStop, &processTotalStop);
if (RT_FAILURE(rc))
{
return 1;
}
RTPrintf("tstCollector: host cpu user = %u.%u %%\n",
RTPrintf("tstCollector: host cpu kernel = %u.%u %%\n",
RTPrintf("tstCollector: host cpu idle = %u.%u %%\n",
RTPrintf("tstCollector: process cpu user = %u.%u %%\n",
(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");
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
#endif
#if 1
#endif
#if 1
#endif
#if 1
#endif
#if 1
RTPrintf("tstCollector: TESTING - Performance\n\n");
#endif
delete collector;
printf ("\ntstCollector FINISHED.\n");
return rc;
}