stam.h revision fe4309b52e5c41dde223c0ccfcb66fdfaaef113f
/** @file
* STAM - Statistics Manager. (VMM)
*/
/*
* Copyright (C) 2006-2007 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_stam_h
#define ___VBox_stam_h
#ifdef _MSC_VER
# if _MSC_VER >= 1400
# include <intrin.h>
# endif
#endif
/** @defgroup grp_stam The Statistics Manager API
* @{
*/
#if defined(VBOX_WITHOUT_RELEASE_STATISTICS) && defined(VBOX_WITH_STATISTICS)
# error "Both VBOX_WITHOUT_RELEASE_STATISTICS and VBOX_WITH_STATISTICS are defined! Make up your mind!"
#endif
/** @def STAM_GET_TS
* Gets the CPU timestamp counter.
*
* @param u64 The 64-bit variable which the timestamp shall be saved in.
*/
#ifdef __GNUC__
# if defined(RT_ARCH_X86)
/* This produces optimal assembler code for x86 but does not work for AMD64 ('A' means 'either rax or rdx') */
# elif defined(RT_ARCH_AMD64)
# define STAM_GET_TS(u64) \
} while (0)
# endif
#else
# if _MSC_VER >= 1400
# define STAM_GET_TS(u64) \
# else
# define STAM_GET_TS(u64) \
do { \
__asm { \
} \
} while (0)
# endif
#endif
/** @def STAM_REL_STATS
* Code for inclusion only when VBOX_WITH_STATISTICS is defined.
* @param code A code block enclosed in {}.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
# define STAM_REL_STATS(code) do {} while(0)
#endif
/** @def STAM_STATS
* Code for inclusion only when VBOX_WITH_STATISTICS is defined.
* @param code A code block enclosed in {}.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_STATS(code) do {} while(0)
#endif
/**
* Sample type.
*/
typedef enum STAMTYPE
{
/** Invalid entry. */
STAMTYPE_INVALID = 0,
/** Generic counter. */
/** Profiling of an function. */
/** Profiling of an operation. */
/** Ratio of A to B, uint32_t types. Not reset. */
/** Ratio of A to B, uint32_t types. Reset both to 0. */
/** Callback. */
/** Generic unsigned 8-bit value. Not reset. */
/** Generic unsigned 8-bit value. Reset to 0. */
/** Generic hexadecimal unsigned 8-bit value. Not reset. */
/** Generic hexadecimal unsigned 8-bit value. Reset to 0. */
/** Generic unsigned 16-bit value. Not reset. */
/** Generic unsigned 16-bit value. Reset to 0. */
/** Generic hexadecimal unsigned 16-bit value. Not reset. */
/** Generic hexadecimal unsigned 16-bit value. Reset to 0. */
/** Generic unsigned 32-bit value. Not reset. */
/** Generic unsigned 32-bit value. Reset to 0. */
/** Generic hexadecimal unsigned 32-bit value. Not reset. */
/** Generic hexadecimal unsigned 32-bit value. Reset to 0. */
/** Generic unsigned 64-bit value. Not reset. */
/** Generic unsigned 64-bit value. Reset to 0. */
/** Generic hexadecimal unsigned 64-bit value. Not reset. */
/** Generic hexadecimal unsigned 64-bit value. Reset to 0. */
/** The end (exclusive). */
} STAMTYPE;
/**
* Sample visibility type.
*/
typedef enum STAMVISIBILITY
{
/** Invalid entry. */
/** Always visible. */
/** Only visible when used (/hit). */
/** Not visible in the GUI. */
/** The end (exclusive). */
/**
* Sample unit.
*/
typedef enum STAMUNIT
{
/** Invalid entry .*/
STAMUNIT_INVALID = 0,
/** No unit. */
/** Number of calls. */
/** Count of whatever. */
/** Count of bytes. */
/** Count of bytes. */
/** Error count. */
/** Number of occurences. */
/** Ticks. */
/** Ticks per call. */
/** Ticks per occurence. */
/** Ratio of good vs. bad. */
/** Megabytes. */
/** Kilobytes. */
/** Nano seconds. */
/** Nanoseconds per call. */
/** Nanoseconds per call. */
/** Percentage. */
/** Hertz. */
/** The end (exclusive). */
} STAMUNIT;
/** @def STAM_REL_U8_INC
* Increments a uint8_t sample by one.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U8_INC(pCounter) \
do { ++*(pCounter); } while (0)
#else
# define STAM_REL_U8_INC(pCounter) do { } while (0)
#endif
/** @def STAM_U8_INC
* Increments a uint8_t sample by one.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U8_INC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U8_DEC
* Decrements a uint8_t sample by one.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U8_DEC(pCounter) \
do { --*(pCounter); } while (0)
#else
# define STAM_REL_U8_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_U8_DEC
* Decrements a uint8_t sample by one.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U8_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U8_ADD
* Increments a uint8_t sample by a value.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
* @param Addend The value to add.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_U8_ADD
* Increments a uint8_t sample by a value.
*
* @param pCounter Pointer to the uint8_t variable to operate on.
* @param Addend The value to add.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_U16_INC
* Increments a uint16_t sample by one.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U16_INC(pCounter) \
do { ++*(pCounter); } while (0)
#else
# define STAM_REL_U16_INC(pCounter) do { } while (0)
#endif
/** @def STAM_U16_INC
* Increments a uint16_t sample by one.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U16_INC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U16_DEC
* Decrements a uint16_t sample by one.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U16_DEC(pCounter) \
do { --*(pCounter); } while (0)
#else
# define STAM_REL_U16_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_U16_DEC
* Decrements a uint16_t sample by one.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U16_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U16_INC
* Increments a uint16_t sample by a value.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
* @param Addend The value to add.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_U16_INC
* Increments a uint16_t sample by a value.
*
* @param pCounter Pointer to the uint16_t variable to operate on.
* @param Addend The value to add.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_U32_INC
* Increments a uint32_t sample by one.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U32_INC(pCounter) \
do { ++*(pCounter); } while (0)
#else
# define STAM_REL_U32_INC(pCounter) do { } while (0)
#endif
/** @def STAM_U32_INC
* Increments a uint32_t sample by one.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U32_INC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U32_DEC
* Decrements a uint32_t sample by one.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U32_DEC(pCounter) \
do { --*(pCounter); } while (0)
#else
# define STAM_REL_U32_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_U32_DEC
* Decrements a uint32_t sample by one.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U32_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U32_ADD
* Increments a uint32_t sample by value.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
* @param Addend The value to add.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_U32_ADD
* Increments a uint32_t sample by value.
*
* @param pCounter Pointer to the uint32_t variable to operate on.
* @param Addend The value to add.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_U64_INC
* Increments a uint64_t sample by one.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U64_INC(pCounter) \
do { ++*(pCounter); } while (0)
#else
# define STAM_REL_U64_INC(pCounter) do { } while (0)
#endif
/** @def STAM_U64_INC
* Increments a uint64_t sample by one.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U64_INC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U64_DEC
* Decrements a uint64_t sample by one.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_U64_DEC(pCounter) \
do { --*(pCounter); } while (0)
#else
# define STAM_REL_U64_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_U64_DEC
* Decrements a uint64_t sample by one.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_U64_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_U64_ADD
* Increments a uint64_t sample by a value.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
* @param Addend The value to add.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_U64_ADD
* Increments a uint64_t sample by a value.
*
* @param pCounter Pointer to the uint64_t variable to operate on.
* @param Addend The value to add.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/**
* Counter sample - STAMTYPE_COUNTER.
*/
typedef struct STAMCOUNTER
{
/** The current count. */
volatile uint64_t c;
} STAMCOUNTER;
/** Pointer to a counter. */
typedef STAMCOUNTER *PSTAMCOUNTER;
/** Pointer to a const counter. */
typedef const STAMCOUNTER *PCSTAMCOUNTER;
/** @def STAM_REL_COUNTER_INC
* Increments a counter sample by one.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_COUNTER_INC(pCounter) \
do { (pCounter)->c++; } while (0)
#else
# define STAM_REL_COUNTER_INC(pCounter) do { } while (0)
#endif
/** @def STAM_COUNTER_INC
* Increments a counter sample by one.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_COUNTER_INC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_COUNTER_DEC
* Decrements a counter sample by one.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
# define STAM_REL_COUNTER_DEC(pCounter) \
do { (pCounter)->c--; } while (0)
#else
# define STAM_REL_COUNTER_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_COUNTER_DEC
* Decrements a counter sample by one.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_COUNTER_DEC(pCounter) do { } while (0)
#endif
/** @def STAM_REL_COUNTER_ADD
* Increments a counter sample by a value.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
* @param Addend The value to add to the counter.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_COUNTER_ADD
* Increments a counter sample by a value.
*
* @param pCounter Pointer to the STAMCOUNTER structure to operate on.
* @param Addend The value to add to the counter.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_COUNTER_RESET
* Resets the statistics sample.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
# define STAM_REL_COUNTER_RESET(pCounter) do { } while (0)
#endif
/** @def STAM_COUNTER_RESET
* Resets the statistics sample.
*/
#ifndef VBOX_WITH_STATISTICS
#else
# define STAM_COUNTER_RESET(pCounter) do { } while (0)
#endif
/**
* Profiling sample - STAMTYPE_PROFILE.
*/
typedef struct STAMPROFILE
{
/** Number of periods. */
/** Total count of ticks. */
/** Maximum tick count during a sampling. */
/** Minimum tick count during a sampling. */
} STAMPROFILE;
/** Pointer to a profile sample. */
typedef STAMPROFILE *PSTAMPROFILE;
/** Pointer to a const profile sample. */
typedef const STAMPROFILE *PCSTAMPROFILE;
/** @def STAM_REL_PROFILE_ADD_PERIOD
* Adds a period.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param cTicksInPeriod The number of tick (or whatever) of the preiod
* being added. This is only referenced once.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
} while (0)
#else
#endif
/** @def STAM_PROFILE_ADD_PERIOD
* Adds a period.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param cTicksInPeriod The number of tick (or whatever) of the preiod
* being added. This is only referenced once.
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_ADD_PERIOD(pProfile, cTicksInPeriod) STAM_REL_PROFILE_ADD_PERIOD(pProfile, cTicksInPeriod)
#else
#endif
/** @def STAM_REL_PROFILE_START
* Samples the start time of a profiling period.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*
* @remarks Declears a stack variable that will be used by related macros.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_PROFILE_START
* Samples the start time of a profiling period.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*
* @remarks Declears a stack variable that will be used by related macros.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_PROFILE_STOP
* Samples the stop time of a profiling period and updates the sample.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
} while (0)
#else
#endif
/** @def STAM_PROFILE_STOP
* Samples the stop time of a profiling period and updates the sample.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_PROFILE_STOP_EX
* Samples the stop time of a profiling period and updates both the sample
* and an attribution sample.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param pProfile2 Pointer to the STAMPROFILE structure which this
* interval should be attributed to as well. This may be NULL.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
\
if ((pProfile2)) \
{ \
} \
} while (0)
#else
#endif
/** @def STAM_PROFILE_STOP_EX
* Samples the stop time of a profiling period and updates both the sample
* and an attribution sample.
*
* @param pProfile Pointer to the STAMPROFILE structure to operate on.
* @param pProfile2 Pointer to the STAMPROFILE structure which this
* interval should be attributed to as well. This may be NULL.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_STOP_EX(pProfile, pProfile2, Prefix) STAM_REL_PROFILE_STOP_EX(pProfile, pProfile2, Prefix)
#else
#endif
/**
* Advanced profiling sample - STAMTYPE_PROFILE_ADV.
*
* Identical to a STAMPROFILE sample, but the start timestamp
* is stored after the STAMPROFILE structure so the sampling
* can start and stop in different functions.
*/
typedef struct STAMPROFILEADV
{
/** The STAMPROFILE core. */
/** The start timestamp. */
/** Pointer to a advanced profile sample. */
typedef STAMPROFILEADV *PSTAMPROFILEADV;
/** Pointer to a const advanced profile sample. */
typedef const STAMPROFILEADV *PCSTAMPROFILEADV;
/** @def STAM_REL_PROFILE_ADV_START
* Samples the start time of a profiling period.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_PROFILE_ADV_START
* Samples the start time of a profiling period.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_ADV_START(pProfileAdv, Prefix) STAM_REL_PROFILE_ADV_START(pProfileAdv, Prefix)
#else
#endif
/** @def STAM_REL_PROFILE_ADV_STOP
* Samples the stop time of a profiling period (if running) and updates the
* sample.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
if ((pProfileAdv)->tsStart) \
{ \
(pProfileAdv)->tsStart = 0; \
} \
} while (0)
#else
#endif
/** @def STAM_PROFILE_ADV_STOP
* Samples the stop time of a profiling period (if running) and updates the
* sample.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
#else
#endif
/** @def STAM_REL_PROFILE_ADV_STOP_START
* Stops one profile counter (if running) and starts another one.
*
* @param pProfileAdv1 Pointer to the STAMPROFILEADV structure to stop.
* @param pProfileAdv2 Pointer to the STAMPROFILEADV structure to start.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
if ((pProfileAdv1)->tsStart) \
{ \
(pProfileAdv1)->tsStart = 0; \
} \
} while (0)
#else
do { } while (0)
#endif
/** @def STAM_PROFILE_ADV_STOP_START
* Samples the stop time of a profiling period (if running) and updates the
* sample.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
#else
do { } while (0)
#endif
/** @def STAM_REL_PROFILE_ADV_SUSPEND
* Suspends the sampling for a while. This can be useful to exclude parts
* covered by other samples without screwing up the count, and average+min times.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables. The prefix
* must match that of the resume one since it stores the
* suspend time in a stack variable.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
#endif
/** @def STAM_PROFILE_ADV_SUSPEND
* Suspends the sampling for a while. This can be useful to exclude parts
* covered by other samples without screwing up the count, and average+min times.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables. The prefix
* must match that of the resume one since it stores the
* suspend time in a stack variable.
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_ADV_SUSPEND(pProfileAdv, Prefix) STAM_REL_PROFILE_ADV_SUSPEND(pProfileAdv, Prefix)
#else
#endif
/** @def STAM_REL_PROFILE_ADV_RESUME
* Counter to STAM_REL_PROFILE_ADV_SUSPEND.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables. This must
* match the one used with the SUSPEND!
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
} while (0)
#else
#endif
/** @def STAM_PROFILE_ADV_RESUME
* Counter to STAM_PROFILE_ADV_SUSPEND.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param Prefix Identifier prefix used to internal variables. This must
* match the one used with the SUSPEND!
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_ADV_RESUME(pProfileAdv, Prefix) STAM_REL_PROFILE_ADV_RESUME(pProfileAdv, Prefix)
#else
#endif
/** @def STAM_REL_PROFILE_ADV_STOP_EX
* Samples the stop time of a profiling period (if running) and updates both
* the sample and an attribution sample.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param pProfile2 Pointer to the STAMPROFILE structure which this
* interval should be attributed to as well. This may be NULL.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
do { \
if ((pProfileAdv)->tsStart) \
{ \
(pProfileAdv)->tsStart = 0; \
if ((pProfile2)) \
{ \
} \
} \
} while (0)
#else
#endif
/** @def STAM_PROFILE_ADV_STOP_EX
* Samples the stop time of a profiling period (if running) and updates both
* the sample and an attribution sample.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
* @param pProfile2 Pointer to the STAMPROFILE structure which this
* interval should be attributed to as well. This may be NULL.
* @param Prefix Identifier prefix used to internal variables.
*/
#ifdef VBOX_WITH_STATISTICS
# define STAM_PROFILE_ADV_STOP_EX(pProfileAdv, pProfile2, Prefix) STAM_REL_PROFILE_ADV_STOP_EX(pProfileAdv, pProfile2, Prefix)
#else
#endif
/** @def STAM_REL_PROFILE_ADV_IS_RUNNING
* Checks if it is running.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
# define STAM_REL_PROFILE_ADV_IS_RUNNING(pProfileAdv) (false)
#endif
/** @def STAM_PROFILE_ADV_IS_RUNNING
* Checks if it is running.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_PROFILE_ADV_IS_RUNNING(pProfileAdv) (false)
#endif
/** @def STAM_REL_PROFILE_ADV_SET_STOPPED
* Marks the profile counter as stopped.
*
* This is for avoiding screwups in twisty code.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
*/
#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
#else
# define STAM_REL_PROFILE_ADV_SET_STOPPED(pProfileAdv) do { } while (0)
#endif
/** @def STAM_PROFILE_ADV_SET_STOPPED
* Marks the profile counter as stopped.
*
* This is for avoiding screwups in twisty code.
*
* @param pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
*/
#ifdef VBOX_WITH_STATISTICS
#else
# define STAM_PROFILE_ADV_SET_STOPPED(pProfileAdv) do { } while (0)
#endif
/**
* Ratio of A to B, uint32_t types.
* @remark Use STAM_STATS or STAM_REL_STATS for modifying A & B values.
*/
typedef struct STAMRATIOU32
{
/** Sample A. */
/** Sample B. */
} STAMRATIOU32;
/** Pointer to a uint32_t ratio. */
typedef STAMRATIOU32 *PSTAMRATIOU32;
/** Pointer to const a uint32_t ratio. */
typedef const STAMRATIOU32 *PCSTAMRATIOU32;
/** @defgroup grp_stam_r3 The STAM Host Context Ring 3 API
* @ingroup grp_stam
* @{
*/
VMMR3DECL(int) STAMR3RegisterU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
VMMR3DECL(int) STAMR3Register(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
/** @def STAM_REL_REG
* Registers a statistics sample.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
STAM_REL_STATS({ int rcStam = STAMR3Register(pVM, pvSample, enmType, STAMVISIBILITY_ALWAYS, pszName, enmUnit, pszDesc); \
/** @def STAM_REG
* Registers a statistics sample if statistics are enabled.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
/** @def STAM_REL_REG_USED
* Registers a statistics sample which only shows when used.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
STAM_REL_STATS({ int rcStam = STAMR3Register(pVM, pvSample, enmType, STAMVISIBILITY_USED, pszName, enmUnit, pszDesc); \
/** @def STAM_REG_USED
* Registers a statistics sample which only shows when used, if statistics are enabled.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
* @param enmType Sample type. This indicates what pvSample is pointing at.
* @param pszName Sample name. The name is on this form "/<component>/<sample>".
* Further nesting is possible.
* @param enmUnit Sample unit.
* @param pszDesc Sample description.
*/
VMMR3DECL(int) STAMR3RegisterFU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
VMMR3DECL(int) STAMR3RegisterF(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
VMMR3DECL(int) STAMR3RegisterVU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
VMMR3DECL(int) STAMR3RegisterV(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
/**
* Resets the sample.
* @param pVM The VM handle.
* @param pvSample The sample registered using STAMR3RegisterCallback.
*/
/** Pointer to a STAM sample reset callback. */
typedef FNSTAMR3CALLBACKRESET *PFNSTAMR3CALLBACKRESET;
/**
* Prints the sample into the buffer.
*
* @param pVM The VM handle.
* @param pvSample The sample registered using STAMR3RegisterCallback.
* @param pszBuf The buffer to print into.
* @param cchBuf The size of the buffer.
*/
/** Pointer to a STAM sample print callback. */
typedef FNSTAMR3CALLBACKPRINT *PFNSTAMR3CALLBACKPRINT;
VMMR3DECL(int) STAMR3RegisterCallback(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
VMMR3DECL(int) STAMR3RegisterCallbackV(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
/** @def STAM_REL_DEREG
* Deregisters a statistics sample if statistics are enabled.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
*/
/** @def STAM_DEREG
* Deregisters a statistics sample if statistics are enabled.
*
* @param pVM VM Handle.
* @param pvSample Pointer to the sample.
*/
VMMR3DECL(int) STAMR3SnapshotU(PUVM pUVM, const char *pszPat, char **ppszSnapshot, size_t *pcchSnapshot, bool fWithDesc);
VMMR3DECL(int) STAMR3Snapshot(PVM pVM, const char *pszPat, char **ppszSnapshot, size_t *pcchSnapshot, bool fWithDesc);
/**
* Callback function for STAMR3Enum().
*
* @returns non-zero to halt the enumeration.
*
* @param pszName The name of the sample.
* @param enmType The type.
* @param pvSample Pointer to the data. enmType indicates the format of this data.
* @param enmUnit The unit.
* @param enmVisibility The visibility.
* @param pszDesc The description.
* @param pvUser The pvUser argument given to STAMR3Enum().
*/
typedef DECLCALLBACK(int) FNSTAMR3ENUM(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
/** Pointer to a FNSTAMR3ENUM(). */
typedef FNSTAMR3ENUM *PFNSTAMR3ENUM;
/** @} */
/** @} */
#endif