summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2013-04-23 08:51:25 +0300
committersnowleo <schneeleo@gmail.com>2013-04-23 08:51:25 +0300
commit5553ca747c9760557f004d7d3558f98f0828b633 (patch)
tree99cf9dcfa99d33aae5f62a75cd0f1b472e7797f6
parenta74189777a5f6ea72b2f46a51ce415efcc3deba4 (diff)
downloadEssentials-5553ca747c9760557f004d7d3558f98f0828b633.tar
Essentials-5553ca747c9760557f004d7d3558f98f0828b633.tar.gz
Essentials-5553ca747c9760557f004d7d3558f98f0828b633.tar.lz
Essentials-5553ca747c9760557f004d7d3558f98f0828b633.tar.xz
Essentials-5553ca747c9760557f004d7d3558f98f0828b633.zip
Fix tps after Timer changes
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsTimer.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index fe04c1cbc..941dc6482 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -12,11 +12,12 @@ public class EssentialsTimer implements Runnable
{
private final transient IEssentials ess;
private final transient Set<User> onlineUsers = new HashSet<User>();
- private transient long lastPoll = System.currentTimeMillis();
- private final transient LinkedList<Float> history = new LinkedList<Float>();
+ private transient long lastPoll = System.nanoTime();
+ private final LinkedList<Double> history = new LinkedList<Double>();
private int skip1 = 0;
private int skip2 = 0;
private final long maxTime = 10 * 1000000;
+ private final long tickInterval = 50;
EssentialsTimer(final IEssentials ess)
{
@@ -27,8 +28,8 @@ public class EssentialsTimer implements Runnable
public void run()
{
final long startTime = System.nanoTime();
- final long currentTime = System.currentTimeMillis();
- long timeSpent = (currentTime - lastPoll) / 1000;
+ //final long currentTime = System.currentTimeMillis();
+ long timeSpent = (startTime - lastPoll) / 1000;
if (timeSpent == 0)
{
timeSpent = 1;
@@ -37,7 +38,7 @@ public class EssentialsTimer implements Runnable
{
history.remove();
}
- float tps = 100f / timeSpent;
+ double tps = tickInterval * 1000000.0 / timeSpent;
if (tps <= 20)
{
history.add(tps);
@@ -104,10 +105,10 @@ public class EssentialsTimer implements Runnable
}
}
- public float getAverageTPS()
+ public double getAverageTPS()
{
- float avg = 0;
- for (Float f : history)
+ double avg = 0;
+ for (Double f : history)
{
if (f != null)
{