aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2020-03-05 23:13:19 +0000
committerLuck <git@lucko.me>2020-03-05 23:13:19 +0000
commit9b7dd3af75f0b2cc76dfd5a5d317874fa21b4856 (patch)
tree98541a5b6894c6edadc1c0712911519b1607395f /spark-common/src/main/java/me/lucko/spark
parentc8ee229857ce8d624aac4a074469474db8f297d3 (diff)
downloadspark-9b7dd3af75f0b2cc76dfd5a5d317874fa21b4856.tar.gz
spark-9b7dd3af75f0b2cc76dfd5a5d317874fa21b4856.tar.bz2
spark-9b7dd3af75f0b2cc76dfd5a5d317874fa21b4856.zip
Some minor cleanup
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java5
2 files changed, 4 insertions, 3 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java
index c91ceae..a6265c8 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickStatistics.java
@@ -141,7 +141,7 @@ public class TickStatistics implements TickHook.Callback, TickReporter.Callback
/**
- * Rolling average calculator taken.
+ * Rolling average calculator.
*
* <p>This code is taken from PaperMC/Paper, licensed under MIT.</p>
*
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java
index 8713678..492d4ea 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/util/FormatUtil.java
@@ -23,6 +23,8 @@ package me.lucko.spark.common.util;
public enum FormatUtil {
;
+ private static final String[] SIZE_UNITS = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
+
public static String percent(double value, double max) {
double percent = (value * 100d) / max;
return (int) percent + "%";
@@ -32,8 +34,7 @@ public enum FormatUtil {
if (bytes == 0) {
return "0 bytes";
}
- String[] sizes = new String[]{"bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int sizeIndex = (int) (Math.log(bytes) / Math.log(1024));
- return String.format("%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + sizes[sizeIndex];
+ return String.format("%.1f", bytes / Math.pow(1024, sizeIndex)) + " " + SIZE_UNITS[sizeIndex];
}
}