Performance.h revision 6c6531128b39093daeac902a8705c0bdf15b31cc
/* $Id$ */
/** @file
* VirtualBox Main - Performance Classes declaration.
*/
/*
* 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.
*/
#ifndef ___performance_h
#define ___performance_h
#include <algorithm>
#include <functional> /* For std::fun_ptr in testcase */
#include <list>
#include <vector>
/* Forward decl. */
{
/* CPU load is measured in 1/1000 of per cent. */
/* Sub Metrics **********************************************************/
{
bool mWrapped;
};
{
const char *getDescription() { return mDescription; };
const char *mName;
const char *mDescription;
};
enum {
COLLECT_NONE = 0x0,
COLLECT_CPU_LOAD = 0x1,
COLLECT_RAM_USAGE = 0x2,
COLLECT_GUEST_STATS = 0x4
};
typedef int HintFlags;
{
void collectHostCpuLoad()
{ mHostFlags |= COLLECT_CPU_LOAD; }
void collectHostRamUsage()
{ mHostFlags |= COLLECT_RAM_USAGE; }
void collectHostRamVmm()
{ mHostFlags |= COLLECT_GUEST_STATS; }
bool isHostCpuLoadCollected() const
{ return (mHostFlags & COLLECT_CPU_LOAD) != 0; }
bool isHostRamUsageCollected() const
{ return (mHostFlags & COLLECT_RAM_USAGE) != 0; }
bool isHostRamVmmCollected() const
{ return (mHostFlags & COLLECT_GUEST_STATS) != 0; }
{
}
const ProcessList& getProcessFlags() const
{
return mProcesses;
}
{
return *it;
/* Not found -- add new */
return mProcesses.back();
}
};
/* Guest Collector Classes *********************************/
{
~CollectorGuest();
void invalidateStats() { mValid = false; };
int updateStats();
int enable();
int disable();
bool mEnabled;
bool mValid;
};
{
};
/* Collector Hardware Abstraction Layer *********************************/
{
CollectorHAL() {};
virtual ~CollectorHAL() { };
virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; }
/** Returns averaged CPU usage in 1/1000th per cent across all host's CPUs. */
/** Returns the average frequency in MHz across all host's CPUs. */
/** Returns the amount of physical memory in kilobytes. */
/** Returns CPU usage in 1/1000th per cent by a particular process. */
/** Returns the amount of memory used by a process in kilobytes. */
/** Returns CPU usage counters in platform-specific units. */
/** Returns process' CPU usage counter in platform-specific units. */
virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
};
extern CollectorHAL *createHAL();
/* Base Metrics *********************************************************/
{
: mPeriod(0), mLength(0), mHAL(hal), mName(name), mObject(object), mLastSampleTaken(0), mEnabled(false) {};
virtual ~BaseMetric() {};
const char *mName;
bool mEnabled;
};
{
};
{
HostCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
void collect();
const char *getUnit() { return "%"; };
ULONG getMinValue() { return 0; };
};
{
HostCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
void collect();
};
{
void collect();
const char *getUnit() { return "MHz"; };
ULONG getMinValue() { return 0; };
};
{
HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
{
HostRamVmm(CollectorGuestManager *gm, ComPtr<IUnknown> object, SubMetric *allocVMM, SubMetric *freeVMM, SubMetric *balloonVMM, SubMetric *sharedVMM)
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
{
MachineCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
void collect();
const char *getUnit() { return "%"; };
ULONG getMinValue() { return 0; };
};
{
MachineCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
: MachineCpuLoad(hal, object, process, user, kernel), mHostTotalPrev(0), mProcessUserPrev(0), mProcessKernelPrev(0) {};
void collect();
};
{
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
{
GuestCpuLoad(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
void collect();
const char *getUnit() { return "%"; };
ULONG getMinValue() { return 0; };
};
{
GuestRamUsage(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *shared, SubMetric *cache, SubMetric *pagedtotal)
: BaseGuestMetric(cguest, "Guest/RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mShared(shared) {};
~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mShared; delete mCache; delete mPagedTotal; };
void collect();
const char *getUnit() { return "kB"; };
ULONG getMinValue() { return 0; };
};
/* Aggregate Functions **************************************************/
{
};
{
};
{
};
{
};
/* Metric Class *********************************************************/
{
{
if (mAggregate)
{
}
}
~Metric()
{
}
const char *getDescription()
};
/* Filter Class *********************************************************/
{
bool fSeenColon = false);
};
}
#endif /* ___performance_h */
/* vi: set tabstop=4 shiftwidth=4 expandtab: */