From 5b4f62598f5f99a5f56c31d78f20fd944e33d820 Mon Sep 17 00:00:00 2001 From: scamiv <6170744+scamiv@users.noreply.github.com> Date: Sun, 22 Feb 2026 18:00:38 +0100 Subject: [PATCH] fix: Keeps average TPS accurate before 60s have passed. --- src/client/graphics/layers/PerformanceOverlay.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/graphics/layers/PerformanceOverlay.ts b/src/client/graphics/layers/PerformanceOverlay.ts index 9a15f8b76..b4a0d4634 100644 --- a/src/client/graphics/layers/PerformanceOverlay.ts +++ b/src/client/graphics/layers/PerformanceOverlay.ts @@ -600,7 +600,10 @@ export class PerformanceOverlay extends LitElement implements Layer { const ticksLast1s = this.tickTimestamps.length - this.tickHead1s; const ticksLast60s = this.tickTimestamps.length - this.tickHead60s; this.currentTPS = ticksLast1s; - this.averageTPS = Math.round((ticksLast60s / 60) * 10) / 10; + const oldest60 = + ticksLast60s > 0 ? this.tickTimestamps[this.tickHead60s] : now; + const elapsed60s = Math.min(60, Math.max(1, (now - oldest60) / 1000)); + this.averageTPS = Math.round((ticksLast60s / elapsed60s) * 10) / 10; // Compact occasionally to avoid unbounded growth on long sessions. if (this.tickHead60s > 4000) {