From 7c614e33f5c050a4e6f83cfbc7b7bd259700778a Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 16 Jun 2019 17:02:39 +0100 Subject: Add option to ignore "sleeping" threads when sampling --- .../java/me/lucko/spark/common/command/modules/SamplerModule.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'spark-common/src/main/java/me/lucko/spark/common/command') diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java index ee16830..fe7ffe0 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java @@ -76,6 +76,7 @@ public class SamplerModule implements CommandModule { .argumentUsage("interval", "interval millis") .argumentUsage("only-ticks-over", "tick length millis") .argumentUsage("include-line-numbers", null) + .argumentUsage("ignore-sleeping", null) .executor((platform, sender, resp, arguments) -> { if (arguments.boolFlag("info")) { if (this.activeSampler == null) { @@ -135,6 +136,7 @@ public class SamplerModule implements CommandModule { } boolean includeLineNumbers = arguments.boolFlag("include-line-numbers"); + boolean ignoreSleeping = arguments.boolFlag("ignore-sleeping"); Set threads = arguments.stringFlag("thread"); ThreadDumper threadDumper; @@ -186,6 +188,7 @@ public class SamplerModule implements CommandModule { } builder.samplingInterval(intervalMillis); builder.includeLineNumbers(includeLineNumbers); + builder.ignoreSleeping(ignoreSleeping); if (ticksOver != -1) { builder.ticksOver(ticksOver, tickCounter); } @@ -198,7 +201,7 @@ public class SamplerModule implements CommandModule { resp.broadcastPrefixed(TextComponent.of("The results will be automatically returned after the profiler has been running for " + timeoutSeconds + " seconds.")); } - CompletableFuture future = activeSampler.getFuture(); + CompletableFuture future = this.activeSampler.getFuture(); // send message if profiling fails future.whenCompleteAsync((s, throwable) -> { @@ -230,7 +233,7 @@ public class SamplerModule implements CommandModule { List opts = new ArrayList<>(Arrays.asList("--info", "--stop", "--cancel", "--timeout", "--regex", "--combine-all", "--not-combined", "--interval", - "--only-ticks-over", "--include-line-numbers")); + "--only-ticks-over", "--include-line-numbers", "--ignore-sleeping")); opts.removeAll(arguments); opts.add("--thread"); // allowed multiple times -- cgit