Fixed rounding

Fixed Byte to Megabyte conversion
This commit is contained in:
Fuzzlemann 2017-07-27 19:42:38 +02:00
parent 71f7210a82
commit 2e5c75aede
3 changed files with 5 additions and 4 deletions

View File

@ -76,7 +76,7 @@ public class TPSCountTimer extends AbsRunnable {
Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory();
long usedMemory = (totalMemory - runtime.freeMemory()) / (1024L * 1024L);
long usedMemory = (totalMemory - runtime.freeMemory()) / 1000000;
int playersOnline = plugin.getServer().getOnlinePlayers().size();
int loadedChunks = getLoadedChunks();
@ -114,7 +114,7 @@ public class TPSCountTimer extends AbsRunnable {
diff -= twentySeconds;
}
double tpsN = twentySeconds / diff;
double tpsN = MathUtils.round(twentySeconds / diff);
return new TPS(now, tpsN, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded);
}

View File

@ -179,6 +179,8 @@ public class MathUtils {
* @return The rounded number
*/
public static double round(double number) {
return Double.valueOf(decimalFormat.format(number));
String formattedNumber = decimalFormat.format(number);
formattedNumber = formattedNumber.substring(0, 3); //Fix for unknown reasons for not-rounding
return Double.valueOf(formattedNumber);
}
}

View File

@ -154,5 +154,4 @@ public class MathUtilsTest {
double result = MathUtils.sumDouble(l.stream());
assertTrue(result + "/" + exp, exp == result);
}
}