Class MetricsCollector
- Namespace
- DotCompute.Core.Telemetry
- Assembly
- DotCompute.Core.dll
High-performance metrics collector for kernel execution, memory usage, and device utilization. Provides real-time metrics collection with minimal performance impact (less than 1%).
public sealed class MetricsCollector : IDisposable
- Inheritance
-
MetricsCollector
- Implements
- Inherited Members
- Extension Methods
Constructors
MetricsCollector(ILogger<MetricsCollector>)
Initializes a new instance of the MetricsCollector class.
public MetricsCollector(ILogger<MetricsCollector> logger)
Parameters
loggerILogger<MetricsCollector>The logger.
Methods
CollectAllMetricsAsync(CancellationToken)
Collects all available metrics for export to monitoring systems.
public Task<CollectedMetrics> CollectAllMetricsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
DetectBottlenecks()
Detects performance bottlenecks and returns optimization recommendations.
public IReadOnlyList<PerformanceBottleneck> DetectBottlenecks()
Returns
Dispose()
Performs dispose.
public void Dispose()
GetCurrentMemoryUsage()
Gets current memory usage across all devices.
public long GetCurrentMemoryUsage()
Returns
GetDevicePerformanceMetrics(string)
Gets device-specific performance metrics including temperature and utilization trends.
public DevicePerformanceMetrics? GetDevicePerformanceMetrics(string deviceId)
Parameters
deviceIdstring
Returns
GetDeviceUtilization()
Gets current device utilization as a weighted average across all devices.
public double GetDeviceUtilization()
Returns
GetKernelPerformanceMetrics(string)
Gets comprehensive performance metrics for a specific kernel.
public KernelPerformanceMetrics? GetKernelPerformanceMetrics(string kernelName)
Parameters
kernelNamestring
Returns
GetMemoryAccessAnalysis(TimeSpan)
Gets memory access patterns for optimization analysis.
public MemoryAccessAnalysis GetMemoryAccessAnalysis(TimeSpan timeWindow)
Parameters
timeWindowTimeSpan
Returns
RecordKernelExecution(string, string, TimeSpan, long, bool, KernelExecutionDetails)
Records kernel execution metrics with detailed performance characteristics.
public void RecordKernelExecution(string kernelName, string deviceId, TimeSpan executionTime, long memoryUsed, bool success, KernelExecutionDetails details)
Parameters
kernelNamestringdeviceIdstringexecutionTimeTimeSpanmemoryUsedlongsuccessbooldetailsKernelExecutionDetails
RecordMemoryOperation(string, string, long, TimeSpan, bool, MemoryOperationDetails)
Records memory allocation and transfer operations with bandwidth analysis.
public void RecordMemoryOperation(string operationType, string deviceId, long bytes, TimeSpan duration, bool success, MemoryOperationDetails details)