mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Fix TPS calculation: clamp values above 20 instead of discarding them
The old code filtered out any instantaneous TPS sample > 20 with `if (tps <= 20 && tps > 0)`. Because time-update packets arrive with OS/network jitter, many measurements on a healthy server land slightly above 20.0 and were silently discarded, leaving only sub-20 samples in the rolling average. This caused the reported TPS to be virtually always lower than the true server TPS. A Minecraft server cannot genuinely run faster than 20 TPS (it sleeps for the remainder of each 50 ms tick budget), so any measurement above 20 is definitionally timing noise. Clamp to Math.Min(tps, 20.0) instead of discarding the sample so a healthy server's rolling average converges to 20.0 as expected. Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/826926c5-78fa-4059-ab8f-4abd209f120d Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
This commit is contained in:
parent
bca4532328
commit
744dcd73cd
1 changed files with 6 additions and 2 deletions
|
|
@ -3912,11 +3912,15 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
DateTime currentTime = DateTime.Now;
|
DateTime currentTime = DateTime.Now;
|
||||||
long tickDiff = WorldAge - lastAge;
|
long tickDiff = WorldAge - lastAge;
|
||||||
Double tps = tickDiff / (currentTime - lastTime).TotalSeconds;
|
double tps = tickDiff / (currentTime - lastTime).TotalSeconds;
|
||||||
lastAge = WorldAge;
|
lastAge = WorldAge;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
if (tps <= 20 && tps > 0)
|
if (tps > 0)
|
||||||
{
|
{
|
||||||
|
// A Minecraft server cannot genuinely exceed 20 TPS; values above 20 are
|
||||||
|
// caused by packet-timing jitter. Clamp instead of discarding so that a
|
||||||
|
// healthy server averages to 20 rather than being biased downward.
|
||||||
|
tps = Math.Min(tps, 20.0);
|
||||||
// calculate average tps
|
// calculate average tps
|
||||||
if (tpsSamples.Count >= maxSamples)
|
if (tpsSamples.Count >= maxSamples)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue