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
MinimumDurationThreshold
Gets the current minimum duration threshold.
TimeSpan MinimumDurationThreshold { get; }
Property Value
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
operationNamestringName 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
formatMetricsExportFormatFormat for exporting the data
operationFilterFunc<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
operationNamestringName 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
operationNamestringName of the operation
durationTimeSpanDuration of the operation
operationIdstringOptional unique identifier for this operation instance
metadataIDictionary<string, object>Optional metadata associated with the operation
SetEnabled(bool)
Enables or disables timing collection.
void SetEnabled(bool enabled)
Parameters
enabledboolWhether 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
thresholdTimeSpanMinimum duration threshold
StartOperation(string, string?)
Starts timing an operation with the specified name.
ITimerHandle StartOperation(string operationName, string? operationId = null)
Parameters
operationNamestringName of the operation being timed
operationIdstringOptional 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
operationNamestringName of the operation being timed
operationIdstringOptional 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
Returns
- TimeSpan
Duration of the operation
TimeOperationAsync(string, Func<Task>)
Times a void asynchronous operation.
Task<TimeSpan> TimeOperationAsync(string operationName, Func<Task> operation)
Parameters
operationNamestringName of the operation being timed
operationFunc<Task>The async operation to time
Returns
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
operationNamestringName of the operation being timed
operationFunc<Task<T>>The async operation to time
Returns
Type Parameters
TReturn 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
Returns
Type Parameters
TReturn type of the operation
Events
OperationCompleted
Event fired when an operation completes and timing data is recorded.
event EventHandler<OperationTimingEventArgs> OperationCompleted