Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

PerfData.h File Reference

Performance counter support. More...

#include <OW32/OW32libs.h>
#include <OW32/windows.h>
#include <winperf.h>
#include <string>
#include <map>
#include <OW32/tstl.h>
#include <OW32/XHANDLE.h>
#include <OW32/SyncObjects.h>

Go to the source code of this file.

Namespaces

namespace  OW32

Classes

class  OW32::CPerfDataException
 The general exception thrown by CPerfData and friends. More...
class  OW32::CPerfData
 Performance data helper. More...
class  OW32::CPerfObject
 Represents a performance object. More...
class  OW32::CPerfCounter
 A performance counter definition. More...

Defines

#define PERF_DECLARE_MAP(appName)   extern OW32::CPerfData g_perfData_##appName;
 Declares a performance map.
#define PERF_DEFINE_OBJECT(sym, val)   const OW32::CPerfData::ObjectId sym = (OW32::CPerfData::ObjectId)val;
 Defines a performance object.
#define PERF_DEFINE_COUNTER(sym, val)   const OW32::CPerfData::CounterId sym = (OW32::CPerfData::CounterId)val;
 Defines a performance counter.
#define PERF_MAP_BEGIN(appName)
 Defines a performance counter map for the application.
#define PERF_MAP_BEGIN_OBJECT(objectId, name, help, detailLevel, defaultCounterId, maxInstances, maxInstanceName)
 Defines a performance object.
#define PERF_MAP_COUNTER(counterId, name, help, detailLevel, defaultScale, type)
 Defines a performance counter.
#define PERF_MAP_COUNTER_SHARED(counterId, counterIdData, name, help, detailLevel, defaultScale, type)
 Defines a performance counter that shares data with another.
#define PERF_MAP_END_OBJECT()   } \
 Ends a performance object definition.
#define PERF_MAP_END(appName)
 Ends a performance object map.
#define PERF_IMPLEMENT_COLLECTOR(appName)
 Implement the performance data collection entry points.
#define PERF_IMPLEMENT_COLLECTOR_REGISTRATION(appName)
 Implements the entry points DllRegisterServer and DllUnregisterServer.

Variables

OW32_LIB_EXPORT CPerfObject
OW32_LIB_EXPORT CPerfCounter


Detailed Description

Performance counter support.


Define Documentation

#define PERF_DECLARE_MAP appName   )     extern OW32::CPerfData g_perfData_##appName;
 

Declares a performance map.

Parameters:
appName The application name
Declares the global object, g_perfData_appName, that can be used to access counters. Typicall included in the header file along with PERF_DEFINE_OBJECT and PERF_DEFINE_COUNTER.

#define PERF_DEFINE_COUNTER sym,
val   )     const OW32::CPerfData::CounterId sym = (OW32::CPerfData::CounterId)val;
 

Defines a performance counter.

Parameters:
sym The symbolic name of the counter
val The symbolic name of the object
Both symbols and values must be unique. See PERF_DEFINE_OBJECT for a note about usage of these two macros.

#define PERF_DEFINE_OBJECT sym,
val   )     const OW32::CPerfData::ObjectId sym = (OW32::CPerfData::ObjectId)val;
 

Defines a performance object.

Parameters:
sym The symbolic name of the object
val The numeric value to assign to the object
Both symbols and values must be unique. PERF_DEFINE_OBJECT and PERF_DEFINE_COUNTER should be placed in a header file which can then be included where the application requires access to the performance counters.

#define PERF_IMPLEMENT_COLLECTOR appName   ) 
 

Implement the performance data collection entry points.

You should use this in your performance data collection DLL. You must also include the following in the module definition file:

EXPORTS OW32_PerfData_appName_Open OW32_PerfData_appName_Close OW32_PerfData_appName_Collect

It is not sensible to attempt to do this with __declspec(dllexport) as this decorates the names rather randomly between compiler versions.

You may call this more than once to implement entry points for different application names within a single DLL if desired. Note that collector registration must be implemented manually in that case.

#define PERF_IMPLEMENT_COLLECTOR_REGISTRATION appName   ) 
 

Implements the entry points DllRegisterServer and DllUnregisterServer.

This allows the required performance counter information to be inserted/removed from the registry by using regsvr32 (/u) on the performance data collector DLL.

This also provides a DllMain that stores the modules instance handle so that the path to the DLL can later be retrieved.

You must also include the following in the module definition file: EXPORTS DllRegisterServer PRIVATE DllUnregisterServer PRIVATE

#define PERF_MAP_BEGIN appName   ) 
 

Value:

OW32::CPerfData g_perfData_##appName(L#appName); \
    class CPerfMapConstructor \
    { \
    public: \
        CPerfMapConstructor(OW32::CPerfData *perfData); \
    }; \
    \
    CPerfMapConstructor::CPerfMapConstructor(OW32::CPerfData *perfData) \
    {
Defines a performance counter map for the application.

There may be multiple performance counter maps if desired, with multiple performance data collection functions. This is not terribly useful in general, but is allowed...

Parameters:
appName The name of the application, as used in HKLM.

#define PERF_MAP_BEGIN_OBJECT objectId,
name,
help,
detailLevel,
defaultCounterId,
maxInstances,
maxInstanceName   ) 
 

Value:

{ \
            static OW32::CPerfObject currentObject( \
                perfData, objectId, L##name, L##help, detailLevel, defaultCounterId, \
                static_cast<DWORD>(maxInstances), maxInstanceName);
Defines a performance object.

Must appear after PERF_MAP_BEGIN.

Parameters:
objectId The id of the object, as declared by PERF_DEFINE_OBJECT.
name The name of the object
help The help text for the object
detailLevel The detail level to show this object at (e.g. PERF_DETAIL_NOVICE)
defaultCounterId The default counter to select in the perfmon dialogue
maxInstances The maximum number of instances for this object. If there can only ever be one instance, then use PERF_NO_INSTANCES, and instance management becomes unnecessary.
maxInstanceName The maximum number of characters in an instance name. Can only be zero if PERF_NO_INSTANCES is specified for maxInstances.

#define PERF_MAP_COUNTER counterId,
name,
help,
detailLevel,
defaultScale,
type   ) 
 

Value:

{ \
                static OW32::CPerfCounter currentCounter( \
                    &currentObject, counterId, L##name, L##help, detailLevel, \
                    static_cast<DWORD>(defaultScale), type); \
            }
Defines a performance counter.

Must appear after PERF_MAP_BEGIN_OBJECT.

Parameters:
counterId The id of the counter, as declared by PERF_DEFINE_COUNTER.
name The name of the counter
help The help text for the counter
detailLevel The detail level to show this counter at (e.g. PERF_DETAIL_NOVICE)
defaultScale The default scale for this counter
type The performance counter type (see winperf reference)

#define PERF_MAP_COUNTER_SHARED counterId,
counterIdData,
name,
help,
detailLevel,
defaultScale,
type   ) 
 

Value:

{ \
                static OW32::CPerfCounter currentCounter( \
                    &currentObject, counterId, L##name, L##help, detailLevel, defaultScale, type, counterIdData); \
            }
Defines a performance counter that shares data with another.

Must appear after PERF_MAP_BEGIN_OBJECT.

This is useful when you want both a rate (PERF_COUNTER_COUNTER) and a total counter which share the same data.

This macro must appear after the PERF_MAP_COUNTER entry for the parent counter.

Parameters:
counterId The id of the counter, as declared by PERF_DEFINE_COUNTER.
counterIdData The id of the counter that contains the base data
name The name of the counter
help The help text for the counter
detailLevel The detail level to show this counter at (e.g. PERF_DETAIL_NOVICE)
defaultScale The default scale for this counter
type The performance counter type (see winperf reference)

#define PERF_MAP_END appName   ) 
 

Value:

} \
    static CPerfMapConstructor s_constructPerfData(&g_perfData_##appName);
Ends a performance object map.

Must appear after PERF_MAP_BEGIN.

Parameters:
appName The name of the application, as used in HKLM.

 
#define PERF_MAP_END_OBJECT  )     } \
 

Ends a performance object definition.

Must appear after PERF_MAP_BEGIN_OBJECT.


Generated on Sun Jun 5 01:29:19 2005 for OW32 by  doxygen 1.3.9.1