perf_counter

Apply this attribute to a data member in a perf_object class to expose it as a performance counter.

[ perf_counter(
      namestring,
      helpstring,
      name_res,
      help_res,
      countertype,
      defscale,
      default_counter,
      detail,
      countertype,
      max_counter_size,
      countertype_string
) ]

Parameters

  • namestring
    A string containing the name of the performance counter. This name will be visible to users in the Performance Monitoring Console. Alternately, the name can be provided in the form of a resource ID using the name_res argument. A performance counter name must be specified using one of these two arguments.

  • helpstring
    A string containing a description of the performance counter. This help string will be visible to users in the Performance Monitoring Console. Alternately, the name can be provided in the form of a resource ID using the help_res argument. A help string must be specified using one of these two arguments.

  • name_res
    An integer that specifies the resource ID of the name to for this performance counter. This name will be visible to users in the Performance Monitoring Console. If this argument is provided, the namestring argument must be omitted.

  • help_res
    An integer that specifies the resource ID of a description for this performance counter. This help string will be visible to users in the Performance Monitoring Console. If this argument is provided, the helpstring argument must be omitted.

  • countertype
    An integer that specifies the counter type. See the "Calculations for Raw Counter Data" entry in the MSDN Library for more information. Alternately, the countertype_string argument can be used.

  • defscale
    An exponential value that modifies the actual counter value. Default is zero.

  • default_counter
    A Boolean value that specifies that this is the default counter for the object. An object can have only one default counter. Default is false.

  • detail
    An integer that specifies the desired detail level of the counter, and is PERF_DETAIL_NOVICE by default. Can be any one of these values:

    Detail level

    Description

    PERF_DETAIL_NOVICE

    Indicates that this counter may be meaningful to most users. This is the most common counter detail level.

    PERF_DETAIL_ADVANCED

    Indicates that this counter is likely to be useful only to advanced users.

    PERF_DETAIL_EXPERT

    Indicates that this counter is likely to be useful only to the most advanced users.

    PERF_DETAIL_WIZARD

    Indicates that this counter is not likely to be useful to any users.

  • max_counter_size
    An integer that specifies the maximum amount of space to reserve for the data of a string counter. By default this value is zero, which indicates no maximum value. Numeric counters, those whose counter type includes the flags PERF_SIZE_DWORD or PERF_SIZE_LARGE, are fixed size and may not specify this parameter.

  • countertype_string
    Specifies the counter type as a string. If this argument is provided, the countertype argument must be omitted. This argument can be any one of the following strings:

    countertype_string

    Performance data types

    "counter"

    PERF_COUNTER_COUNTER

    "timer"

    PERF_COUNTER_TIMER

    "bulk_count"

    PERF_COUNTER_BULK_COUNT

    "text"

    PERF_COUNTER_TEXT

    "rawcount"

    PERF_COUNTER_RAWCOUNT

    "value"

    PERF_COUNTER_VALUE

    "rate"

    PERF_COUNTER_RATE

    "fraction"

    PERF_COUNTER_FRACTION

    "base"

    PERF_COUNTER_BASE

    "elapsed"

    PERF_COUNTER_ELAPSED

    "queuelen"

    PERF_COUNTER_QUEUELEN

    "histogram"

    PERF_COUNTER_HISTOGRAM

    "precision"

    PERF_COUNTER_PRECISION

    See the "Calculations for Raw Counter Data" entry in the MSDN Library for more information.

Requirements

Attribute Context

Applies to

Data member

Repeatable

No

Required attributes

None

Invalid attributes

None

For more information about the attribute contexts, see Attribute Contexts.

Requirements

Header

atlperf.h

Project

EXE, DLL

Compiler

/D "_ATL_ATTRIBUTES"

For more information about the meaning of the requirements, see Attribute Requirements.

Remarks

This attribute is applied to a data member that will serve as a performance counter. The class containing the new counter must be defined using the perf_object attribute.

The counter name and help string are required arguments but can be provided in either string or resource form. Both arguments must, however, be provided in the same form. The counter type is also a required argument, and can be specified in either string or integer form.

For the following type of counters, a [perf_counter] entry for Type 1 should always be followed by an entry for a [perf_counter] of Type 2. For example, a PERF_AVERAGE_TIMER entry should be followed by one for PERF_AVERAGE_BASE.

Perf Counter Type 1

Perf Counter Type 2

PERF_AVERAGE_BULK

PERF_AVERAGE_BASE

PERF_AVERAGE_TIMER

PERF_AVERAGE_BASE

PERF_RAW_FRACTION

PERF_RAW_BASE

PERF_SAMPLE_COUNTER

PERF_SAMPLE_BASE

PERF_SAMPLE_FRACTION

PERF_SAMPLE_BASE

PERF_COUNTER_MULTI_TIMER

PERF_COUNTER_MULTI_BASE

PERF_COUNTER_MULTI_TIMER_INV

PERF_COUNTER_MULTI_BASE

PERF_100NSEC_MULTI_TIMER

PERF_COUNTER_MULTI_BASE

PERF_100NSEC_MULTI_TIMER_INV

PERF_COUNTER_MULTI_BASE

Example

#include <atlperf.h> 
[ perf_object( namestring = "MyPerfObject", helpstring = "Object Help") ]
class CMyPerfObject
{
   [ perf_counter(namestring="MyCounter", helpstring="Counter Help",
     countertype_string="rawcount") ]
   ULONG m_nCounter;
};

#define _ATL_ATTRIBUTES
#include <atlperf.h>
[ perf_object( namestring = "MyPerfObject", helpstring = "Object Help") ]
class CMyPerfObject
{
   [ 
     perf_counter(namestring = "MyRawFraction", 
     helpstring = "Raw Fraction Help", 
     countertype = PERF_RAW_FRACTION)
   ]
   ULONG m_nRF;
   [
      perf_counter(namestring = "MyRawFractionBase", 
      helpstring = "Raw Fraction Base Help", 
      countertype = PERF_RAW_BASE)
   ]
   ULONG m_nRFBase;
};

See Also

Concepts

perf_object

perfmon

COM Attributes

Data Member Attributes

ATL Samples