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" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Performance" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Performance&version=6.0.0
                    
Install as a Cake Tool

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 PerformanceMonitoringLoggingService for automatic structured logging via Oakrey.Log.
  • Implements IDisposable for 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.1
  • Oakrey.Log >= 2.0.0
  • System.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-windows and relies on Windows-specific performance counter APIs via Oakrey.Debug.Windows.
  • PerformanceMonitoringLoggingService implements IPreLoadable, 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 PerformanceMonitoringService when the application shuts down to release the underlying PerformanceMonitor.

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 90 5/22/2026
2.0.4 93 5/22/2026
2.0.3 95 5/15/2026
2.0.2 152 3/13/2026
2.0.1 112 2/11/2026
2.0.0 444 11/18/2025
1.0.2 230 9/29/2025
1.0.1 299 8/8/2025
1.0.0 305 8/6/2025