This commit is contained in:
2023-03-02 22:07:43 +02:00
parent 1a0709d113
commit 5e48806b8c
21 changed files with 145 additions and 82 deletions

View File

@@ -14,9 +14,12 @@ namespace Game
private Label label;
private Stopwatch stopwatch;
private Stopwatch stopwatch2;
private double updateTimeAvg;
private double updateTimeAvg2;
private ulong updateTimeCount;
private ulong updateTimeCount2;
public override void OnAwake()
{
@@ -25,10 +28,20 @@ namespace Game
control.HideFlags = HideFlags.None;
stopwatch = Stopwatch.StartNew();
stopwatch2 = Stopwatch.StartNew();
}
public override void OnUpdate()
{
updateTimeCount2++;
double elapsed2 = stopwatch2.Elapsed.TotalSeconds;
if (elapsed2 >= updateInterval * 10)
{
stopwatch2.Restart();
updateTimeAvg2 = elapsed2 / updateTimeCount2;
updateTimeCount2 = 0;
}
updateTimeCount++;
double elapsed = stopwatch.Elapsed.TotalSeconds;
if (elapsed >= updateInterval)
@@ -52,7 +65,7 @@ namespace Game
#endif
label.Text += $"{triangles} tris\n {drawCalls} drawcalls\n";
label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg2)}fps2\n";
label.Text += $"{(int)Math.Round(1.0f / updateTimeAvg)}fps";
}