mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
bugfix: Fix TPS average bias caused by discarding samples above 20
This commit is contained in:
commit
a16af89dac
1 changed files with 6 additions and 2 deletions
|
|
@ -3912,11 +3912,15 @@ namespace MinecraftClient
|
|||
{
|
||||
DateTime currentTime = DateTime.Now;
|
||||
long tickDiff = WorldAge - lastAge;
|
||||
Double tps = tickDiff / (currentTime - lastTime).TotalSeconds;
|
||||
double tps = tickDiff / (currentTime - lastTime).TotalSeconds;
|
||||
lastAge = WorldAge;
|
||||
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
|
||||
if (tpsSamples.Count >= maxSamples)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue