System.Diagnostics.PerformanceCounter
A class defining the counter type, name and help string for a custom counter.
A struct holding the raw data for a performance counter.
Raw value of the counter.
Optional base raw value for the counter (only used if multiple counter based).
Raw system frequency
Raw counter frequency
Raw counter frequency
Raw timestamp
Raw high fidelity timestamp
Counter type
Static functions to calculate the performance value off the sample
Static functions to calculate the performance value off the samples
Set of utility functions for interpreting the counter data
Converts 100NS elapsed time to fractional seconds
Computes the calculated value given a raw counter sample.
Computes the calculated value given a raw counter sample.
A holder of instance data.
A collection containing all the instance data for a counter. This collection is contained in the
when using the
method.
The collection returned from the method.
that contains all the counter and instance data.
The collection contains an InstanceDataCollection object for each counter. Each InstanceDataCollection
object contains the performance data for all counters for that instance. In other words the data is
indexed by counter name and then by instance name.
Performance Counter component.
This class provides support for NT Performance counters.
It handles both the existing counters (accessible by Perf Registry Interface)
and user defined (extensible) counters.
This class is a part of a larger framework, that includes the perf dll object and
perf service.
The defaut constructor. Creates the perf counter object
Creates the Performance Counter Object
Creates the Performance Counter Object on local machine.
Creates the Performance Counter Object on local machine.
Creates the Performance Counter Object, assumes that it's a single instance
Creates the Performance Counter Object, assumes that it's a single instance
Returns the performance category name for this performance counter
Returns the description message for this performance counter
Sets/returns the performance counter name for this performance counter
Sets/Returns the counter type for this performance counter
Sets/returns an instance name for this performance counter
Returns true if counter is read only (system counter, foreign extensible counter or remote counter)
Set/returns the machine name for this performance counter
Directly accesses the raw value of this counter. If counter type is of a 32-bit size, it will truncate
the value given to 32 bits. This can be significantly more performant for scenarios where
the raw value is sufficient. Note that this only works for custom counters created using
this component, non-custom counters will throw an exception if this property is accessed.
Frees all the resources allocated by this counter
Frees all the resources allocated for all performance
counters, frees File Mapping used by extensible counters,
unloads dll's used to read counters.
Decrements counter by one using an efficient atomic operation.
Increments the value of this counter. If counter type is of a 32-bit size, it'll truncate
the value given to 32 bits. This method uses a mutex to guarantee correctness of
the operation in case of multiple writers. This method should be used with caution because of the negative
impact on performance due to creation of the mutex.
Increments counter by one using an efficient atomic operation.
Intializes required resources
Obtains a counter sample and returns the raw value for it.
Obtains a counter sample and returns the calculated value for it.
NOTE: For counters whose calculated value depend upon 2 counter reads,
the very first read will return 0.0.
Removes this counter instance from the shared memory
A Performance counter category object.
Creates a PerformanceCounterCategory object for given category.
Uses the local machine.
Creates a PerformanceCounterCategory object for given category.
Uses the given machine name.
Gets/sets the Category name
Gets/sets the Category help
Gets/sets the Machine name
Returns true if the counter is registered for this category
Returns true if the counter is registered for this category on the current machine.
Returns true if the counter is registered for this category on a particular machine.
Registers one extensible performance category of type NumberOfItems32 with the system
Registers the extensible performance category with the system on the local machine
Removes the counter (category) from the system
Returns true if the category is registered on the current machine.
Returns true if the category is registered in the machine.
Returns the instance names for a given category
Returns an array of counters in this category. The counter must have only one instance.
Returns an array of counters in this category for the given instance.
Returns an array of performance counter categories for the current machine.
Returns an array of performance counter categories for a particular machine.
Returns an array of instances for this category
Returns true if the instance already exists for this category.
Returns true if the instance already exists for the category specified.
Returns true if the instance already exists for this category and machine specified.
Reads all the counter and instance data of this performance category. Note that reading the entire category
at once can be as efficient as reading a single counter because of the way the system provides the data.
Enum of friendly names to counter types (maps directory to the native types)
CounterSet is equivalent to "Counter Object" in native performance counter terminology,
or "Counter Category" in previous framework releases. It defines a abstract grouping of
counters, where each counter defines measurable matrix. In the new performance counter
infrastructure, CounterSet is defined by GUID called CounterSetGuid, and is hosted inside
provider application, which is also defined by another GUID called ProviderGuid.
CounterSet constructor.
ProviderGuid identifies the provider application. A provider identified by ProviderGuid could publish several CounterSets defined by different CounterSetGuids
CounterSetGuid identifies the specific CounterSet. CounterSetGuid should be unique.
One of defined CounterSetInstanceType values
Add non-displayable new counter to CounterSet; that is, perfmon would not display the counter.
CounterId uniquely identifies the counter within CounterSet
One of defined CounterType values
Add named new counter to CounterSet.
CounterId uniquely identifies the counter within CounterSet
One of defined CounterType values
This is friendly name to help provider developers as indexer. and it might not match what is displayed in counter consumption applications lie perfmon.
Create instances of the CounterSet. Created CounterSetInstance identifies active identity and tracks raw counter data for that identity.
Friendly name identifies the instance. InstanceName would be shown in counter consumption applications like perfmon.
CounterSetInstance object
CounterSetInstance class maps to "Instance" in native performance counter implementation.
Access CounterSetInstanceCounterDataSet property. Developers can then use defined indexer to access
specific CounterData object to query/update raw counter data.
CounterData class is used to store actual raw counter data. It is the value element within
CounterSetInstanceCounterDataSet, which is part of CounterSetInstance.
CounterData constructor
The memory location to store raw counter data
Value property it used to query/update actual raw counter data.
RawValue property it used to query/update actual raw counter data.
This property is not thread-safe and should only be used
for performance-critical single-threaded access.
CounterSetInstanceCounterDataSet is part of CounterSetInstance class, and is used to store raw counter data
for all counters added in CounterSet.
CounterId indexer to access specific CounterData object.
CounterId that matches one CounterSet::AddCounter()call
CounterData object with matched counterId
CounterName indexer to access specific CounterData object.
CounterName that matches one CounterSet::AddCounter() call
CounterData object with matched counterName
Enum of friendly names to CounterSet instance type (maps directory to the native types defined in perflib.h)
Single means that at any time CounterSet should only have at most 1 active instance.
Multiple means that CounterSet could have multiple active instances.
GlobalAggregate means that CounterSet could have multiple active instances, but counter consumption
applications (for example, perfmon) would aggregate raw counter data from different instances.
GlobalAggregateWithHistory is similar to GlobalAggregate, but counter consumption applications
(for example, permfon) would aggregate raw counter data not only from active instances, but also
from instances since consumption applications start.
MultipleInstancesWithAggregate acts similar to Multiple, but it also generate aggregated instace
"_Total" that hosts aggregated raw counter data from all other instances.
InstanceAggregate only exists in Longhonr Server. Counter consumption applications aggregate raw
counter data for active instances with the same instance name.
Enum of friendly names to counter types (maps directory to the native types defined in winperf.h).
Invalid value '{1}' for parameter '{0}'.
Cannot load Category Help data because an invalid index '{0}' was read from the registry. Performance counters on the machine may need to be repaired.
Cannot load Counter Name data because an invalid index '{0}' was read from the registry. Performance counters on the machine may need to be repaired.
Cannot load Performance Counter data because an unexpected registry key value type was read from '{0}'. Performance counters on the machine may need to be repaired.
Instance names used for writing to custom counters must be 127 characters or less.
PerformanceCounterInstanceLifetime.Process is not valid in the global shared memory. If your performance counter category was created with an older version of the Framework, it uses the global shared memory. Either use PerformanceCounterInstanceLifetime. ...
Custom counters file view is out of memory.
Cannot continue the current operation, the performance counters memory mapping has been corrupted.
Category '{0}' is marked as single-instance. Performance counters in this category can only be created without instance names.
Category '{0}' is marked as multi-instance. Performance counters in this category can only be created with instance names.
An instance with a lifetime of Process can only be accessed from a PerformanceCounter with the InstanceLifetime set to PerformanceCounterInstanceLifetime.Process.
An instance with a lifetime of Global can only be accessed from a PerformanceCounter with the InstanceLifetime set to PerformanceCounterInstanceLifetime.Global.
Instance '{0}' already exists with a lifetime of Process. It cannot be recreated or reused until it has been removed or until the process using it has exited.
Cannot access shared memory, AppDomain has been unloaded.
Cannot initialize security descriptor initialized.
Cannot create file mapping.
Cannot map view of file.
MismatchedCounterTypes=Mismatched counter types.
There was an error calculating the PerformanceCounter value (0x{0}).
Only objects of type CounterCreationData can be added to a CounterCreationDataCollection.
Instance '{0}' does not exist in the specified Category.
Could not Read Category Index: {0}.
Category does not exist.
The Counter layout for the Category specified is invalid, a counter of the type: AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns, CounterMultiTimer100NsInverse, RawFraction, or SampleFraction has to be i ...
Counter '{0}' does not exist in the specified Category.
Help Not Available
Category {0} does not exist.
Counter {0} does not exist.
Cannot create or delete the Performance Category '{0}' because access is denied.
Invalid value {1} for property {0}.
Category name property has not been set.
Cannot create Performance Category '{0}' because it already exists.
Invalid category name. Its length must be in the range between '{0}' and '{1}'. Double quotes, control characters and leading or trailing spaces are not allowed.
Category names must be 1024 characters or less.
Invalid counter name. Its length must be in the range between '{0}' and '{1}'. Double quotes, control characters and leading or trailing spaces are not allowed.
Invalid help string. Its length must be in the range between '{0}' and '{1}'.
Invalid empty or null string for counter name.
Cannot create Performance Category with counter name {0} because the name is a duplicate.
Cannot delete Performance Category because this category is not registered or is a system category.
Counter is not single instance, an instance name needs to be specified.
Instance {0} does not exist in category {1}.
The InstanceLifetime cannot be set after the instance has been initialized. You must use the default constructor and set the CategoryName, InstanceName, CounterName, InstanceLifetime and ReadOnly properties manually before setting the RawValue.
Cannot update Performance Counter, this object has been initialized as ReadOnly.
Writeable performance counters are not allowed when running in AppContainer.
Failed to initialize because CategoryName is missing.
Failed to initialize because CounterName is missing.
InstanceLifetime is unused by ReadOnly counters.
Cannot write to a Performance Counter in a remote machine.
The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
Single instance categories are only valid with the Global lifetime.
Counter is single instance, instance name '{0}' is not valid for this counter category.
Cannot remove Performance Counter Instance, this object as been initialized as ReadOnly.
Could not locate Performance Counter with specified category name '{0}', counter name '{1}'.
Cannot initialize security descriptor initialized.
Cannot open registry key {0} on computer {1}.
Cannot calculate the size of the file view.
Cannot read Category {0}.
Performance Counters are not supported on this platform.
CounterSetInstanceType '{0}' is not a valid CounterSetInstanceType.
CounterSet provider '{0}' not active.
CounterType '{0}' is not a valid CounterType.
Cannot AddCounter to CounterSet '{0}' after CreateCounterSetInstance.
CounterId '{0}' already added to CounterSet '{1}'.
Non-empty instanceName required.
CounterSet '{0}' not installed yet.
Single instance type CounterSet '{0}' can only have 1 CounterSetInstance.
Non-empty counterName required.
CounterName '{0}' already added to CounterSet '{1}'.
CounterSet provider '{0}' not found.
CounterSet '{0}' does not include any counters.
CounterSet '{0}' already registered.
Instance '{0}' already exists in CounterSet '{1}'.
Cannot allocate raw counter data for CounterSet '{0}' Instance '{1}'.
Cannot locate raw counter data location for CounterSet '{0}', Counter '{1}, in Instance '{2}'.
One machine (either '{0}' or local) may not have remote administration enabled, or both machines may not be running the remote registry service.
No remote connection to '{0}' while trying to read the registry.
Cannot access a closed category sample.
Access to the registry key '{0}' is denied.
Blittable version of Windows BOOL type. It is convenient in situations where
manual marshalling is required, or to avoid overhead of regular bool marshalling.
Some Windows APIs return arbitrary integer values although the return type is defined
as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE
or bResult == BOOL.FALSE .
Returns a string message for the specified Win32 error code.
TOKEN_INFORMATION_CLASS enumeration.
Creates a .
Creates a around a registry handle.
Handle to wrap
Whether to control the handle lifetime