diff options
Diffstat (limited to 'spark-common/src/main')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java | 7 | ||||
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java index a6a227f..5d4d84c 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MonitoringModule.java @@ -43,6 +43,7 @@ public class MonitoringModule<S> implements CommandModule<S> { consumer.accept(Command.<S>builder() .aliases("monitoring") .argumentUsage("threshold", "percentage increase") + .argumentUsage("without-gc", null) .executor((platform, sender, arguments) -> { if (this.activeTickMonitor == null) { @@ -53,7 +54,7 @@ public class MonitoringModule<S> implements CommandModule<S> { try { TickCounter tickCounter = platform.newTickCounter(); - this.activeTickMonitor = new ReportingTickMonitor(platform, tickCounter, threshold); + this.activeTickMonitor = new ReportingTickMonitor(platform, tickCounter, threshold, !arguments.boolFlag("without-gc")); } catch (UnsupportedOperationException e) { platform.sendPrefixedMessage(sender, "&cNot supported!"); } @@ -78,8 +79,8 @@ public class MonitoringModule<S> implements CommandModule<S> { private class ReportingTickMonitor extends TickMonitor { private final SparkPlatform<S> platform; - ReportingTickMonitor(SparkPlatform<S> platform, TickCounter tickCounter, int percentageChangeThreshold) { - super(tickCounter, percentageChangeThreshold); + ReportingTickMonitor(SparkPlatform<S> platform, TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) { + super(tickCounter, percentageChangeThreshold, monitorGc); this.platform = platform; } diff --git a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java index a7dd4a8..f3eb441 100644 --- a/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java +++ b/spark-common/src/main/java/me/lucko/spark/monitor/TickMonitor.java @@ -40,14 +40,14 @@ public abstract class TickMonitor implements Runnable, AutoCloseable { private DoubleSummaryStatistics averageTickTime = new DoubleSummaryStatistics(); private double avg; - public TickMonitor(TickCounter tickCounter, int percentageChangeThreshold) { + public TickMonitor(TickCounter tickCounter, int percentageChangeThreshold, boolean monitorGc) { this.tickCounter = tickCounter; this.percentageChangeThreshold = percentageChangeThreshold; this.tickCounter.start(); this.tickCounter.addTickTask(this); - this.garbageCollectionMonitor = new GarbageCollectionMonitor(this); + this.garbageCollectionMonitor = monitorGc ? new GarbageCollectionMonitor(this) : null; } protected abstract void sendMessage(String message); @@ -55,7 +55,9 @@ public abstract class TickMonitor implements Runnable, AutoCloseable { @Override public void close() { this.tickCounter.close(); - this.garbageCollectionMonitor.close(); + if (this.garbageCollectionMonitor != null) { + this.garbageCollectionMonitor.close(); + } } @Override |