summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-05-18 21:42:02 +0100
committerKHobbits <rob@khobbits.co.uk>2013-05-18 21:42:02 +0100
commit293406a603184c87b7e7d40ee8ea5fa0c449da2a (patch)
tree399419a1361206b0cc412c7efd834f71455fbbef
parent727c53eb2bf933a2ead309c849d743d0d0286579 (diff)
downloadEssentials-293406a603184c87b7e7d40ee8ea5fa0c449da2a.tar
Essentials-293406a603184c87b7e7d40ee8ea5fa0c449da2a.tar.gz
Essentials-293406a603184c87b7e7d40ee8ea5fa0c449da2a.tar.lz
Essentials-293406a603184c87b7e7d40ee8ea5fa0c449da2a.tar.xz
Essentials-293406a603184c87b7e7d40ee8ea5fa0c449da2a.zip
Tidy up /gc's TPS output.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsTimer.java13
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java17
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgc.java2
3 files changed, 20 insertions, 12 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index d53336bb2..d2ee913d5 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -18,12 +18,13 @@ public class EssentialsTimer implements Runnable
private int skip2 = 0;
private final long maxTime = 10 * 1000000;
private final long tickInterval = 50;
-
+
EssentialsTimer(final IEssentials ess)
{
this.ess = ess;
+ history.add(20d);
}
-
+
@Override
public void run()
{
@@ -39,7 +40,7 @@ public class EssentialsTimer implements Runnable
history.remove();
}
double tps = tickInterval * 1000000.0 / timeSpent;
- if (tps <= 20)
+ if (tps <= 21)
{
history.add(tps);
}
@@ -73,7 +74,7 @@ public class EssentialsTimer implements Runnable
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
}
}
-
+
count = 0;
final Iterator<String> iterator = onlineUsers.iterator();
while (iterator.hasNext())
@@ -104,7 +105,7 @@ public class EssentialsTimer implements Runnable
user.resetInvulnerabilityAfterTeleport();
}
}
-
+
public double getAverageTPS()
{
double avg = 0;
@@ -114,7 +115,7 @@ public class EssentialsTimer implements Runnable
{
avg += f;
}
- }
+ }
return avg / history.size();
}
}
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index c907a1ad6..a1f364ab8 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -357,13 +357,13 @@ public class Util
break;
}
}
-
+
if (isBlockUnsafe(world, x, y, z))
{
x = Math.round(loc.getX()) == origX ? x - 1 : x + 1;
z = Math.round(loc.getZ()) == origZ ? z - 1 : z + 1;
}
-
+
int i = 0;
while (isBlockUnsafe(world, x, y, z))
{
@@ -527,12 +527,12 @@ public class Util
}
return is;
}
- private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
+ private static DecimalFormat currencyFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatAsCurrency(final BigDecimal value)
{
- dFormat.setRoundingMode(RoundingMode.FLOOR);
- String str = dFormat.format(value);
+ currencyFormat.setRoundingMode(RoundingMode.FLOOR);
+ String str = currencyFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
@@ -549,6 +549,13 @@ public class Util
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
+ private static DecimalFormat threeDPlaces = new DecimalFormat("#,###.###");
+
+ public static String formatDouble(final double value)
+ {
+ threeDPlaces.setRoundingMode(RoundingMode.HALF_UP);
+ return threeDPlaces.format(value);
+ }
public static boolean isInt(final String sInt)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
index 71851f883..1cb0696da 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
@@ -36,7 +36,7 @@ public class Commandgc extends EssentialsCommand
}
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
- sender.sendMessage(_("tps", "" + color + tps));
+ sender.sendMessage(_("tps", "" + color + Util.formatDouble(tps)));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));