diff options
author | snowleo <schneeleo@gmail.com> | 2013-04-23 08:51:25 +0300 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2013-04-23 08:51:25 +0300 |
commit | 2d339a13077f8821b3c0b5efd67a7cee329913bb (patch) | |
tree | f6d90a5f734162030e8b6f38c09882f486d39a29 | |
parent | 1b6f1a88db761518dc8a50049ad086d04af8ef30 (diff) | |
download | Essentials-2d339a13077f8821b3c0b5efd67a7cee329913bb.tar Essentials-2d339a13077f8821b3c0b5efd67a7cee329913bb.tar.gz Essentials-2d339a13077f8821b3c0b5efd67a7cee329913bb.tar.lz Essentials-2d339a13077f8821b3c0b5efd67a7cee329913bb.tar.xz Essentials-2d339a13077f8821b3c0b5efd67a7cee329913bb.zip |
Fix tps after Timer changes
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsTimer.java | 17 |
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) { |