Skip to content

Commit

Permalink
chore(debugging): fps formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrynik committed Feb 27, 2024
1 parent e2f9bbd commit 03c6309
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/Libs/Systems.Debugging/Diagnostics/FrameCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Systems.Debugging.Diagnostics;

public class FrameCounter(Scellecs.Morpeh.World world) : ISystem
{
private const float UpdateFrequencyInSec = .02f;
private const float UpdateFrequencyInSec = .0875f;
private float _elapsedTime;
private int _framesCount;

Expand All @@ -20,13 +20,13 @@ public void OnUpdate(float deltaTime)
++_framesCount;
_elapsedTime += deltaTime;

if (_elapsedTime < UpdateFrequencyInSec)
{
return;
}
if (_elapsedTime < UpdateFrequencyInSec) return;

ref WorldMetaComponent worldMeta =
ref World.Filter.With<WorldMetaComponent>().Build().First().GetComponent<WorldMetaComponent>();
ref WorldMetaComponent worldMeta = ref World.Filter
.With<WorldMetaComponent>()
.Build()
.First()
.GetComponent<WorldMetaComponent>();
worldMeta.FramesPerSec = _framesCount / _elapsedTime;

_framesCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Libs/Systems.Debugging/Render/RenderFramesPerSec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void OnUpdate(float deltaTime)
ImGui.Begin("Diagnostics",
ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoDocking);

ImGui.Text($"FPS: {world.FramesPerSec}");
ImGui.Text($"FPS: {world.FramesPerSec:F2}");

ImGui.End();
}
Expand Down
15 changes: 9 additions & 6 deletions src/Libs/Systems.Debugging/World/SystemsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public void OnUpdate(float deltaTime)
return;
}

DrawSystemsGroup("Initializers", systemsEngine.Initializers.GetInitializersInfo());
DrawSystemsGroup("Systems", systemsEngine.Systems.GetSystemsInfo());
DrawSystemsGroup("FixedSystems", systemsEngine.FixedSystems.GetFixedSystemsInfo());
DrawSystemsGroup("CleanupSystems", systemsEngine.CleanupSystems.GetCleanupSystemsInfo());
DrawSystemsGroup("RenderSystems", systemsEngine.RenderSystems.GetSystemsInfo());
DrawSystemsGroup("LateSystems", systemsEngine.LateSystems.GetLateSystemsInfo());
DrawSystemsGroup("1. Initializers", systemsEngine.Initializers.GetInitializersInfo());

DrawSystemsGroup("2. FixedSystems", systemsEngine.FixedSystems.GetFixedSystemsInfo());
DrawSystemsGroup("3. Systems", systemsEngine.Systems.GetSystemsInfo());
DrawSystemsGroup("4. LateSystems", systemsEngine.LateSystems.GetLateSystemsInfo());

DrawSystemsGroup("5. RenderSystems", systemsEngine.RenderSystems.GetSystemsInfo());

DrawSystemsGroup("[Undetermined] CleanupSystems", systemsEngine.CleanupSystems.GetCleanupSystemsInfo());

ImGui.TreePop();
}
Expand Down

0 comments on commit 03c6309

Please sign in to comment.