Show / Hide Table of Contents

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
Namespace: Eco.Shared.Tools
Assembly: Eco.Shared.dll
Syntax
public class PerformanceCounter : Object

Constructors

PerformanceCounter(String, Int32)

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

AbsoluteMaxValues

Declaration
public const int AbsoluteMaxValues = 1000
Field Value
Type Description
System.Int32

GetTime

Declaration
public static Func<TimeSpan> GetTime
Field Value
Type Description
System.Func<System.TimeSpan>

Head

Declaration
public int Head
Field Value
Type Description
System.Int32

Length

Declaration
public int Length
Field Value
Type Description
System.Int32

MaxValues

Declaration
public readonly int MaxValues
Field Value
Type Description
System.Int32

Values

Declaration
protected readonly PerformanceCounterValue[] Values
Field Value
Type Description
PerformanceCounterValue[]

Properties

Name

Declaration
public string Name { get; }
Property Value
Type Description
System.String

RecordedValues

Declaration
public ReadOnlySpan<PerformanceCounterValue> RecordedValues { get; }
Property Value
Type Description
System.ReadOnlySpan<PerformanceCounterValue>

TotalCount

Declaration
public int TotalCount { get; }
Property Value
Type Description
System.Int32

TotalDuration

Declaration
public TimeSpan TotalDuration { get; }
Property Value
Type Description
System.TimeSpan

Methods

AddMarker()

Add an event marker, which is a durationless event.

Declaration
public void AddMarker()

AddValue(String, Object)

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
Type Description
PerformanceCounterValueRef

AddValue(TimeSpan, String, Object)

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

Aggregate()

Get the min, max, and average for the history of values.

Declaration
public AggregatedValue Aggregate()
Returns
Type Description
AggregatedValue

Aggregate(TimeSpan)

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
Type Description
AggregatedValue

GetRecorders<T>()

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
Name Description
T

TryGetLastValue(out Double)

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.

WithValueRecorder(IValueRecorder)

Empowers PerformanceCounter with valueRecorder. Do it before start using the counter to avoid multi-threading issues.

Declaration
public PerformanceCounter WithValueRecorder(IValueRecorder valueRecorder)
Parameters
Type Name Description
IValueRecorder valueRecorder
Returns
Type Description
PerformanceCounter

Extension Methods

DetectingValueRecorderExtensions.WithPerformanceIssuesDetection(PerformanceCounter, TimeSpan, Boolean)
PerformanceCounterExtensions.AddValueIfActive(PerformanceCounter, String)
CommandLine.FeedFromCommandLine(Object)
CommandLine.ToCommandLineArgs(Object, Func<Object, Boolean>)
ListUtil.DepthFirstTraversal<T>(T, Func<T, IEnumerable<T>>)
EnumerableExtensions.SingleItemAsEnumerable<T>(T)
EventUtils.RaiseEvent<TEventArgs>(Object, String, TEventArgs)
PredicateUtils.MatchesAll<TEnumerable, T>(T, TEnumerable)
PredicateUtils.MatchesAll<T>(T, Func<T, Boolean>[])
PredicateUtils.MatchesAny<TEnumerable, T>(T, TEnumerable)
ReflectionUtils.PropertyValue<T>(Object, PropertyInfo)
ReflectionUtils.TryGetPropertyValueByName<T>(Object, String, out T)
ReflectionUtils.GetPropertyValueByName<T>(Object, String)
ReflectionUtils.SetPropertyByName(Object, String, Object)
ReflectionUtils.GetStructPropertyByName<T>(Object, String)
ReflectionUtils.GetStringPropertyByName(Object, String)
ReflectionUtils.ZipByProperty<T>(Object, Object, Object, Func<T, T, T>)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾