refactor code
This commit is contained in:
+14
-14
@@ -38,9 +38,9 @@ public class ProfilerCommand extends RootNode {
|
||||
super("sprofiler", PERM_BASE);
|
||||
this.profilerManager = profilerManager;
|
||||
children(
|
||||
new StartCommand(),
|
||||
new StartAtCommand(),
|
||||
new StopCommand()
|
||||
StartCommand::new,
|
||||
StartAtCommand::new,
|
||||
StopCommand::new
|
||||
);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StartCommand extends LiteralNode {
|
||||
private StartCommand() {
|
||||
super("start");
|
||||
children(new TypeArg());
|
||||
children(TypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +157,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class TypeArg extends ArgumentNode<String> {
|
||||
private TypeArg() {
|
||||
super("type", StringArgumentType.word());
|
||||
children(new CategoryArg());
|
||||
children(CategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,7 +175,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CategoryArg extends ArgumentNode<String> {
|
||||
private CategoryArg() {
|
||||
super("category", StringArgumentType.word());
|
||||
children(new RegionArg());
|
||||
children(RegionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +193,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class RegionArg extends ArgumentNode<Long> {
|
||||
private RegionArg() {
|
||||
super("regionId", LongArgumentType.longArg(0L));
|
||||
children(new SecondsArg());
|
||||
children(SecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StartAtCommand extends LiteralNode {
|
||||
private StartAtCommand() {
|
||||
super("start-at");
|
||||
children(new CoordinateTypeArg());
|
||||
children(CoordinateTypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,7 +230,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CoordinateTypeArg extends ArgumentNode<String> {
|
||||
private CoordinateTypeArg() {
|
||||
super("coordinateType", StringArgumentType.word());
|
||||
children(new CoordinateCategoryArg());
|
||||
children(CoordinateCategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,7 +248,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class CoordinateCategoryArg extends ArgumentNode<String> {
|
||||
private CoordinateCategoryArg() {
|
||||
super("coordinateCategory", StringArgumentType.word());
|
||||
children(new WorldArg());
|
||||
children(WorldArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,7 +266,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class WorldArg extends ArgumentNode<String> {
|
||||
private WorldArg() {
|
||||
super("world", StringArgumentType.word());
|
||||
children(new BlockXArg());
|
||||
children(BlockXArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,14 +282,14 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class BlockXArg extends ArgumentNode<Integer> {
|
||||
private BlockXArg() {
|
||||
super("blockX", IntegerArgumentType.integer());
|
||||
children(new BlockZArg());
|
||||
children(BlockZArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
private final class BlockZArg extends ArgumentNode<Integer> {
|
||||
private BlockZArg() {
|
||||
super("blockZ", IntegerArgumentType.integer());
|
||||
children(new CoordinateSecondsArg());
|
||||
children(CoordinateSecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ public class ProfilerCommand extends RootNode {
|
||||
private final class StopCommand extends LiteralNode {
|
||||
private StopCommand() {
|
||||
super("stop");
|
||||
children(new SessionArg());
|
||||
children(SessionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -7,7 +7,7 @@ import org.jspecify.annotations.NonNull;
|
||||
|
||||
/**
|
||||
* note: 1.a single instance should be called single threadedly(except method "toggle")
|
||||
* 2.tickEnd, tickBegin, taskEnd, taskBegin are called serially not concurrently, if not, exception or unexpected behavior would be
|
||||
* 2.tickEnd, tickBegin, taskEnd, taskBegin are called serially not concurrently, if not, exception or unexpected behavior would be
|
||||
* surely happened
|
||||
*/
|
||||
public class RegionScheduleProfiler {
|
||||
@@ -91,7 +91,8 @@ public class RegionScheduleProfiler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the execution time of last operation
|
||||
* Gets the execution time of last operation
|
||||
*
|
||||
* @return -1 -> no execution history yet, otherwise the execution time of last operation
|
||||
*/
|
||||
public long lastExecutionTime() {
|
||||
|
||||
+1
-5
@@ -17,11 +17,7 @@ import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
Reference in New Issue
Block a user