Use BigDecimal to improve accracy of TPS results - long live 20 TPS!

It's always been commonly said to 'ignore' that TPS was '19.X', that
it was fine.

I suspect that the inaccuracy of floating point math resulted in us
losing precision over time, making it difficult to actually get back to 20,
as you know the fun 0.1 + 0.1 ... 9 more times != 1 problem.

BigDecimal supports working with doubles with higher precision.

This change makes it so our RollingAverage class maintains all of the data
using BigDecimal and using BigDecimal arithematic operations.

This ensures we have extremely high precision, enabling us to
actually be able print '20 TPS' when TPS is perfect.
This commit is contained in:
Aikar
2018-09-17 22:32:37 -04:00
parent 2b349bb02b
commit 3aaba8c301
11 changed files with 68 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
From de16e4a606f31cb9b6b141bbaf62e7dee398aaaa Mon Sep 17 00:00:00 2001
From 2289cdf49428ff3f05fc5249b217e7714bd013ef Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 15 Jan 2018 22:11:48 -0500
Subject: [PATCH] Basic PlayerProfile API
@@ -429,10 +429,10 @@ index dce1417aff..f7856897f6 100644
* Calculates distance between 2 entities
* @param e1
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 464db5ebb8..3e99221619 100644
index 6a3d5fdff4..65204c259e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1185,7 +1185,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
@@ -1189,7 +1189,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
*/ // CraftBukkit end
String s1 = "."; // PAIL?
@@ -441,7 +441,7 @@ index 464db5ebb8..3e99221619 100644
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(s1, MinecraftServer.a.getName()));
@@ -1634,6 +1634,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
@@ -1638,6 +1638,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.G = i;
}
@@ -523,5 +523,5 @@ index a9e9cc6f4e..c79e673fbf 100644
// Paper end
}
--
2.18.0
2.19.0