Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 887 Bytes

README.md

File metadata and controls

38 lines (24 loc) · 887 Bytes

ModelingEvolution.RateCounters

Lightweight rate counting utilities for .NET: thread-safe rate counters for FPS, throughput, and request rate measurement.

Installation

dotnet add package ModelingEvolution.RateCounters

RateCounter

Thread-safe rate counter that measures events per second over a configurable window.

using ModelingEvolution.RateCounters;

// FPS counter
var fps = new RateCounter();

// In your frame loop:
fps.Tick();  // or: fps++;
Console.WriteLine($"FPS: {fps.Rate:F1}");

// Custom window (default: 5 seconds)
var counter = new RateCounter { MeasureWindow = TimeSpan.FromSeconds(2) };

// Explicit double conversion
double currentRate = (double)counter;

Thread Safety

RateCounter is fully thread-safe. Multiple threads can call Tick() concurrently, and Rate can be read from any thread at any time.

License

MIT