Class PerformanceCounter
A PerformanceCounter is a collection of values with performance data for a single topic.
Values will be grouped together under the PerformanceCounter name, but can optionally have text associated
with them individually too.
Inheritance
System.Object
PerformanceCounter
Assembly: Eco.Shared.dll
public class PerformanceCounter : Object
Constructors
Create a PerformanceCounter with the maximum number of historical values stored.
Declaration
public PerformanceCounter(string name, int maxValues = 1000)
Parameters
| Type |
Name |
Description |
| System.String |
name |
|
| System.Int32 |
maxValues |
|
Fields
Declaration
public const int AbsoluteMaxValues = 1000
Field Value
| Type |
Description |
| System.Int32 |
|
Declaration
public static Func<TimeSpan> GetTime
Field Value
| Type |
Description |
| System.Func<System.TimeSpan> |
|
Declaration
Field Value
| Type |
Description |
| System.Int32 |
|
Declaration
Field Value
| Type |
Description |
| System.Int32 |
|
Declaration
public readonly int MaxValues
Field Value
| Type |
Description |
| System.Int32 |
|
Declaration
protected readonly PerformanceCounterValue[] Values
Field Value
Properties
Declaration
public string Name { get; }
Property Value
| Type |
Description |
| System.String |
|
Declaration
public ReadOnlySpan<PerformanceCounterValue> RecordedValues { get; }
Property Value
Declaration
public int TotalCount { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
Declaration
public TimeSpan TotalDuration { get; }
Property Value
| Type |
Description |
| System.TimeSpan |
|
Methods
Add an event marker, which is a durationless event.
Declaration
Add a value with an optional name. Call Dispose to end duration time, or use a using block.
Declaration
public PerformanceCounterValueRef AddValue(string name = null, object context = null)
Parameters
| Type |
Name |
Description |
| System.String |
name |
|
| System.Object |
context |
|
Returns
Add a value with an optional name with known duration.
Declaration
public void AddValue(TimeSpan duration, string name = null, object context = null)
Parameters
| Type |
Name |
Description |
| System.TimeSpan |
duration |
|
| System.String |
name |
|
| System.Object |
context |
|
Get the min, max, and average for the history of values.
Declaration
public AggregatedValue Aggregate()
Returns
Get the min, max, and average for the specified period of time.
Declaration
public AggregatedValue Aggregate(TimeSpan period)
Parameters
| Type |
Name |
Description |
| System.TimeSpan |
period |
|
Returns
Returns all value recorders of type T.
Declaration
public IEnumerable<T> GetRecorders<T>()
where T : IValueRecorder
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<T> |
|
Type Parameters
Attempts to retrieve the last value stored.
Declaration
public bool TryGetLastValue(out double value)
Parameters
| Type |
Name |
Description |
| System.Double |
value |
Value stored if it exists. Otherwise 0
|
Returns
| Type |
Description |
| System.Boolean |
true if a value was retrieved. Otherwise false.
|
Empowers PerformanceCounter with valueRecorder. Do it before start using the counter to avoid multi-threading issues.
Declaration
public PerformanceCounter WithValueRecorder(IValueRecorder valueRecorder)
Parameters
Returns
Extension Methods