mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 02:55:23 +01:00
Make CPU profiling interval configurable.
Also lower the default to something more sensible. Also cleanup unused imports.
This commit is contained in:
parent
f2d2f47394
commit
d6c2504bbf
@ -21,7 +21,6 @@
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -47,7 +46,6 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -146,9 +146,9 @@ public void report(CommandContext args, final Actor sender) throws CommandExcept
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"profile"}, usage = "[<minutes>]",
|
||||
@Command(aliases = {"profile"}, usage = "[-p] [-i <interval>] [-t <thread filter>] [<minutes>]",
|
||||
desc = "Profile the CPU usage of the server", min = 0, max = 1,
|
||||
flags = "t:p")
|
||||
flags = "t:i:p")
|
||||
@CommandPermissions("worldguard.profile")
|
||||
public void profile(final CommandContext args, final Actor sender) throws CommandException, AuthorizationException {
|
||||
Predicate<ThreadInfo> threadFilter;
|
||||
@ -182,6 +182,16 @@ public void profile(final CommandContext args, final Actor sender) throws Comman
|
||||
}
|
||||
}
|
||||
|
||||
int interval = 20;
|
||||
if (args.hasFlag('i')) {
|
||||
interval = args.getFlagInteger('i');
|
||||
if (interval < 1 || interval > 100) {
|
||||
throw new CommandException("Interval must be between 1 and 100 (in milliseconds)");
|
||||
}
|
||||
if (interval < 10) {
|
||||
sender.printDebug("Note: A low interval may cause additional slowdown during profiling.");
|
||||
}
|
||||
}
|
||||
Sampler sampler;
|
||||
|
||||
synchronized (this) {
|
||||
@ -192,6 +202,7 @@ public void profile(final CommandContext args, final Actor sender) throws Comman
|
||||
SamplerBuilder builder = new SamplerBuilder();
|
||||
builder.setThreadFilter(threadFilter);
|
||||
builder.setRunTime(minutes, TimeUnit.MINUTES);
|
||||
builder.setInterval(interval);
|
||||
sampler = activeSampler = builder.start();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
|
@ -22,7 +22,6 @@
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.commands.CommandUtils;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
|
@ -27,8 +27,6 @@
|
||||
import com.sk89q.worldguard.session.MoveType;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class WeatherLockFlag extends FlagValueChangeHandler<WeatherType> {
|
||||
|
||||
public static final Factory FACTORY = new Factory();
|
||||
|
@ -49,7 +49,7 @@ public int getInterval() {
|
||||
}
|
||||
|
||||
public void setInterval(int interval) {
|
||||
checkArgument(interval >= 10, "interval >= 10");
|
||||
checkArgument(interval >= 1, "interval >= 1");
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.report.ReportList;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||
import com.sk89q.worldguard.session.Session;
|
||||
|
Loading…
Reference in New Issue
Block a user