Working with Performance Counters

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 10.  Testing and Debugging


Performance counters are Windows's way of collecting performance data from running processes. Windows organizes performance counters into categories. Each category defines a specific set of performance counters. For example, there are categories such as Memory, Processor, and PhysicalDisk; the Memory category has various counters, such as Available Bytes, Cache Bytes, and Committed Bytes.

Some categories are further divided into instances. For example, the Process category is divided into several instances, each representing a running process on the computer. A new instance is added to the category whenever a new process is started, and the instance is removed when a process is killed. Each instance can have performance counters (such as I/O Read Bytes/sec) that specify the memory activity of a process. Usually all the instances in a category have the same list of performance counters. Of course, each of the performance counters has unique performance data associated with it.

The PerformanceCounter class enables you to read performance samples for processes that are running on a machine. By using this class, an application can even publish its own performance counter to inform the world about its performance level.

Table 10.7 lists some important members of the PerformanceCounter class.

Table 10.7. Important Members of the PerformanceCounter Class

Member

Type

Description

CategoryName

Property

Specifies the performance counter category name.

Close()

Method

Closes the performance counter and frees all the resources.

CounterHelp

Property

Specifies the performance counter description.

CounterName

Property

Specifies the performance counter name.

CounterType

Property

Specifies the performance counter type.

Decrement()

Method

Decrements the performance counter value by one.

Increment()

Method

Increments the performance counter value by one.

IncrementBy()

Method

Increments or decrements the performance counter value by a specified amount.

InstanceName

Property

Specifies the instance name.

MachineName

Property

Specifies the computer name.

NextSample()

Method

Returns an object of type CounterSample that has properties such as RawValue, BaseValue, TimeStamp, and SystemFrequency. These properties provide you with detailed information on the performance data.

NextValue()

Method

Retrieves the current calculated value (a float type) for a performance counter.

RawValue

Property

Retrieves the raw, or uncalculated, value for a performance counter.

ReadOnly

Property

Indicates whether the PerformanceCounter object is in read-only mode.

RemoveInstance()

Method

Deletes an instance from the PerformanceCounter object.

The .NET Framework allows applications to create custom performance counters and publish their performance data. This performance data can then be monitored via the Performance Monitoring tool (perfmon.exe).

Visual Studio .NET makes it easy for you to create new performance categories and counters: It provides the Performance Counter Builder Wizard, which is available via Server Explorer. Open Server Explorer and, from the Servers node, select the server in which you want to create a performance counter. Right-click the Performance Counters node and select the Create New Category option. The Performance Counter Builder dialog box appears. Enter the values in the dialog box and then click OK to create the category and the counter.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net