BerylliumFrameRateCounter 2.0.0

dotnet add package BerylliumFrameRateCounter --version 2.0.0
                    
NuGet\Install-Package BerylliumFrameRateCounter -Version 2.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="BerylliumFrameRateCounter" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BerylliumFrameRateCounter" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BerylliumFrameRateCounter" />
                    
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 BerylliumFrameRateCounter --version 2.0.0
                    
#r "nuget: BerylliumFrameRateCounter, 2.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 BerylliumFrameRateCounter@2.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=BerylliumFrameRateCounter&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BerylliumFrameRateCounter&version=2.0.0
                    
Install as a Cake Tool

BerylliumFrameRateCounter

Simple frame rate counter for game and render loops.

Feed it the duration of each frame; it reports frames per second, the most recent frame time, and the worst frame time seen in the current window.

Install

dotnet add package BerylliumFrameRateCounter

Usage

using Beryllium.Diagnostics;

private readonly FrameRateCounter _counter = new();

protected override void Update(GameTime gameTime)
{
    _counter.Update(gameTime.ElapsedGameTime.TotalSeconds);
    base.Update(gameTime);
}

protected override void Draw(GameTime gameTime)
{
    _spriteBatch.DrawString(_font, $"{_counter.FrameRate} FPS", Vector2.Zero, Color.White);
    _spriteBatch.DrawString(_font, $"worst {_counter.WorstFrameTimePerRefresh * 1000f:F2} ms",
        new Vector2(0f, 20f), Color.White);
}

API

Member Description
Update(double elapsedSeconds) Records one frame. Negative and non-finite values are ignored.
FrameRate Frames per second, rounded to the nearest whole frame.
FrameTime Duration of the most recent frame, in seconds.
WorstFrameTimePerRefresh Longest frame time in the last completed interval.
RefreshIntervalSeconds Averaging window length. Defaults to 0.5. Must be finite and positive.
UpdateEveryFrame Recompute from every frame instead of averaging. Responsive, but jittery.
Reset() Clears all statistics. Leaves configuration alone.

Instances are not thread-safe — call Update from the loop thread only.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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
2.0.0 119 8/22/2026
1.0.1 135 7/2/2026
1.0.0 264 2/10/2025