Skip to content

Commit

Permalink
Add FrameRateProfilerRecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
noir-neo committed Mar 14, 2024
1 parent cc98199 commit dc8b180
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions Assets/Hatbor/Scripts/LifetimeScope/MainLifetimeScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protected override void Configure(IContainerBuilder builder)

// PerformanceProfiler
builder.RegisterEntryPoint<PerformanceProfilerTicker>();
builder.Register<IProfilerRecorder, FrameRateProfilerRecorder>(Lifetime.Singleton).AsSelf();
builder.Register<IProfilerRecorder, VmcServerProfilerRecorder>(Lifetime.Singleton).AsSelf();

// Rig/VMC
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using UniRx;

namespace Hatbor.PerformanceProfiler
{
public sealed class FrameRateProfilerRecorder : IProfilerRecorder
{
readonly ReactiveProperty<string> text = new();
IReadOnlyReactiveProperty<string> IProfilerRecorder.Text => text;

int count;
float time;

void IProfilerRecorder.Tick(float t)
{
count++;
time += t;
if (!(time >= 1f)) return;
var frameRate = count / time;
text.Value = $"Frame Rate: {frameRate:F2}/s";
time = 0f;
count = 0;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc8b180

Please sign in to comment.