Oakrey.Applications.Performance
6.0.0
dotnet add package Oakrey.Applications.Performance --version 6.0.0
NuGet\Install-Package Oakrey.Applications.Performance -Version 6.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Oakrey.Applications.Performance" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.Performance" Version="6.0.0" />
<PackageReference Include="Oakrey.Applications.Performance" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Oakrey.Applications.Performance --version 6.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Oakrey.Applications.Performance, 6.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Oakrey.Applications.Performance@6.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.Applications.Performance&version=6.0.0
#tool nuget:?package=Oakrey.Applications.Performance&version=6.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Oakrey.Applications.Performance
A .NET 10 Windows library for real-time CPU and RAM performance monitoring. Usage data is exposed as reactive IObservable streams, with optional automatic logging integration and support for dependency injection.
Main Features
- Real-time CPU usage monitoring exposed as
IObservable<int>(percent). - Real-time RAM usage monitoring exposed as
IObservable<int>(MB). - Aggregated
IObservable<PerformanceLog>stream for combined diagnostics. - Configurable polling interval (default: 1000 ms).
- Optional
PerformanceMonitoringLoggingServicefor automatic structured logging viaOakrey.Log. - Implements
IDisposablefor clean resource management. - Designed for use with dependency injection containers.
Architecture
classDiagram
class IPerformanceMonitoringService {
+IObservable~int~ CpuUsage
+IObservable~int~ RamUsage
+IObservable~PerformanceLog~ Usage
}
class PerformanceMonitoringService {
+PerformanceMonitoringService(msPeriod)
+PerformanceMonitoringService()
+Dispose()
}
class PerformanceMonitoringLoggingService {
+PerformanceMonitoringLoggingService(IPerformanceMonitoringService)
+Dispose()
+Preload(CancellationToken)
}
IPerformanceMonitoringService <|.. PerformanceMonitoringService
PerformanceMonitoringLoggingService --> IPerformanceMonitoringService
| Class | Responsibility |
|---|---|
IPerformanceMonitoringService |
Public contract for CPU/RAM observable streams |
PerformanceMonitoringService |
Core implementation using Oakrey.Debug.Windows.PerformanceMonitor |
PerformanceMonitoringLoggingService |
Subscribes to Usage and logs each tick via Oakrey.Log |
Requirements
- .NET 10 (Windows)
Oakrey.Debug.Windows>= 3.0.1Oakrey.Log>= 2.0.0System.Reactive>= 6.1.0
Installation
.NET CLI
dotnet add package Oakrey.Applications.Performance
Package Manager Console
Install-Package Oakrey.Applications.Performance
NuGet Package Manager
Search for Oakrey.Applications.Performance under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Configuration
PerformanceMonitoringService accepts an optional polling interval in milliseconds. The default is 1000 ms.
// Default interval (1000 ms)
IPerformanceMonitoringService monitor = new PerformanceMonitoringService();
// Custom interval
IPerformanceMonitoringService monitor = new PerformanceMonitoringService(msPeriod: 500);
Example Usage
Subscribe to individual streams
using Oakrey.Applications.Performance;
using PerformanceMonitoringService monitor = new PerformanceMonitoringService(msPeriod: 1000);
monitor.CpuUsage.Subscribe(cpu => Console.WriteLine($"CPU: {cpu}%"));
monitor.RamUsage.Subscribe(ram => Console.WriteLine($"RAM: {ram} MB"));
Subscribe to the combined log stream
monitor.Usage.Subscribe(log => Console.WriteLine($"CPU: {log.CPU}%, RAM: {log.RAM} MB"));
Dependency injection registration
services.AddSingleton<IPerformanceMonitoringService>(
_ => new PerformanceMonitoringService(msPeriod: 1000));
// Optional: automatic logging on each tick
services.AddSingleton<PerformanceMonitoringLoggingService>();
Development Notes
- The project targets
net10.0-windowsand relies on Windows-specific performance counter APIs viaOakrey.Debug.Windows. PerformanceMonitoringLoggingServiceimplementsIPreLoadable, which integrates with the Oakrey application startup pipeline.- All observable subjects are
BehaviorSubject<int>, so new subscribers immediately receive the last known value. - Always dispose
PerformanceMonitoringServicewhen the application shuts down to release the underlyingPerformanceMonitor.
Project Information
| Property | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| NuGet package | Oakrey.Applications.Performance |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/ApplicationServices |
| Package URL | https://www.oakrey.cz/opkg_applications |
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-windows7.0
- Oakrey.Applications.Abstractions (>= 6.0.0)
- Oakrey.Debug.Windows (>= 3.0.1)
- Oakrey.Log (>= 2.0.1)
- System.Reactive (>= 6.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.