Table of Contents

Interface IOperationTimer

Namespace
DotCompute.Abstractions.Interfaces.Telemetry
Assembly
DotCompute.Abstractions.dll

Interface for high-precision operation timing and performance measurement. Provides methods for measuring execution times, collecting metrics, and analyzing performance patterns.

public interface IOperationTimer : IDisposable
Inherited Members
Extension Methods

Properties

IsEnabled

Gets whether timing collection is currently enabled.

bool IsEnabled { get; }

Property Value

bool

MinimumDurationThreshold

Gets the current minimum duration threshold.

TimeSpan MinimumDurationThreshold { get; }

Property Value

TimeSpan

Methods

ClearAllStatistics()

Clears all timing data for all operations.

void ClearAllStatistics()

ClearStatistics(string)

Clears all timing data for a specific operation.

void ClearStatistics(string operationName)

Parameters

operationName string

Name of the operation to clear data for

ExportData(MetricsExportFormat, Func<string, bool>?)

Exports timing data in the specified format.

string ExportData(MetricsExportFormat format, Func<string, bool>? operationFilter = null)

Parameters

format MetricsExportFormat

Format for exporting the data

operationFilter Func<string, bool>

Optional filter for which operations to include

Returns

string

Exported timing data as a string

GetAllStatistics()

Gets timing statistics for all recorded operations.

IDictionary<string, OperationStatistics> GetAllStatistics()

Returns

IDictionary<string, OperationStatistics>

Dictionary mapping operation names to their statistics

GetStatistics(string)

Gets timing statistics for a specific operation.

OperationStatistics? GetStatistics(string operationName)

Parameters

operationName string

Name of the operation to get statistics for

Returns

OperationStatistics

Timing statistics for the operation, or null if no data exists

RecordTiming(string, TimeSpan, string?, IDictionary<string, object>?)

Records a manual timing measurement for an operation.

void RecordTiming(string operationName, TimeSpan duration, string? operationId = null, IDictionary<string, object>? metadata = null)

Parameters

operationName string

Name of the operation

duration TimeSpan

Duration of the operation

operationId string

Optional unique identifier for this operation instance

metadata IDictionary<string, object>

Optional metadata associated with the operation

SetEnabled(bool)

Enables or disables timing collection.

void SetEnabled(bool enabled)

Parameters

enabled bool

Whether timing should be enabled

SetMinimumDurationThreshold(TimeSpan)

Sets the minimum duration threshold for recording operations. Operations faster than this threshold will be ignored.

void SetMinimumDurationThreshold(TimeSpan threshold)

Parameters

threshold TimeSpan

Minimum duration threshold

StartOperation(string, string?)

Starts timing an operation with the specified name.

ITimerHandle StartOperation(string operationName, string? operationId = null)

Parameters

operationName string

Name of the operation being timed

operationId string

Optional unique identifier for this operation instance

Returns

ITimerHandle

A timer handle that can be used to stop the operation

StartOperationScope(string, string?)

Starts timing an operation and automatically stops when the returned handle is disposed.

IDisposable StartOperationScope(string operationName, string? operationId = null)

Parameters

operationName string

Name of the operation being timed

operationId string

Optional unique identifier for this operation instance

Returns

IDisposable

A disposable timer handle

TimeOperation(string, Action)

Times a void synchronous operation.

TimeSpan TimeOperation(string operationName, Action operation)

Parameters

operationName string

Name of the operation being timed

operation Action

The operation to time

Returns

TimeSpan

Duration of the operation

TimeOperationAsync(string, Func<Task>)

Times a void asynchronous operation.

Task<TimeSpan> TimeOperationAsync(string operationName, Func<Task> operation)

Parameters

operationName string

Name of the operation being timed

operation Func<Task>

The async operation to time

Returns

Task<TimeSpan>

Task containing the duration of the operation

TimeOperationAsync<T>(string, Func<Task<T>>)

Times an asynchronous operation and returns the result along with timing information.

Task<(T result, TimeSpan duration)> TimeOperationAsync<T>(string operationName, Func<Task<T>> operation)

Parameters

operationName string

Name of the operation being timed

operation Func<Task<T>>

The async operation to time

Returns

Task<(T result, TimeSpan duration)>

Task containing the operation result and timing information

Type Parameters

T

Return type of the operation

TimeOperation<T>(string, Func<T>)

Times a synchronous operation and returns the result along with timing information.

(T result, TimeSpan duration) TimeOperation<T>(string operationName, Func<T> operation)

Parameters

operationName string

Name of the operation being timed

operation Func<T>

The operation to time

Returns

(T result, TimeSpan duration)

Tuple containing the operation result and timing information

Type Parameters

T

Return type of the operation

Events

OperationCompleted

Event fired when an operation completes and timing data is recorded.

event EventHandler<OperationTimingEventArgs> OperationCompleted

Event Type

EventHandler<OperationTimingEventArgs>