mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-27 06:20:05 +00:00
Fix profiler
This commit is contained in:
1 parent
1457a10b0b
commit
df3d3c6398
12 files changed
+23
-38
No files matched your search
@@ -1,17 +1,11 @@
|
|||||||
package com.dfsek.terra;
|
package com.dfsek.terra;
|
||||||
|
|
||||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.polydev.gaea.profiler.DataType;
|
import org.polydev.gaea.profiler.DataType;
|
||||||
import org.polydev.gaea.profiler.Measurement;
|
import org.polydev.gaea.profiler.Measurement;
|
||||||
import org.polydev.gaea.profiler.WorldProfiler;
|
import org.polydev.gaea.profiler.WorldProfiler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class TerraProfiler extends WorldProfiler {
|
public class TerraProfiler extends WorldProfiler {
|
||||||
private static final Map<World, TerraProfiler> profilerMap = new HashMap<>();
|
|
||||||
|
|
||||||
public TerraProfiler(World w) {
|
public TerraProfiler(World w) {
|
||||||
super(w);
|
super(w);
|
||||||
this
|
this
|
||||||
@@ -22,13 +16,4 @@ public class TerraProfiler extends WorldProfiler {
|
|||||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime")
|
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime")
|
||||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "ElevationTime");
|
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "ElevationTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraProfiler fromWorld(World w) {
|
|
||||||
if(w.getGenerator() instanceof TerraChunkGenerator) {
|
|
||||||
if(profilerMap.containsKey(w)) return profilerMap.get(w);
|
|
||||||
TerraProfiler p = new TerraProfiler(w);
|
|
||||||
profilerMap.put(w, p);
|
|
||||||
return p;
|
|
||||||
} else throw new IllegalArgumentException("Attempted to instantiate/fetch Profiler for non-Terra world!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -18,11 +18,13 @@ public class TerraWorld {
|
|||||||
private final BiomeZone zone;
|
private final BiomeZone zone;
|
||||||
private final ConfigPack config;
|
private final ConfigPack config;
|
||||||
private boolean safe;
|
private boolean safe;
|
||||||
|
private final TerraProfiler profiler;
|
||||||
|
|
||||||
|
|
||||||
public TerraWorld(World w, ConfigPack c) {
|
public TerraWorld(World w, ConfigPack c) {
|
||||||
safe = true;
|
safe = true;
|
||||||
config = c;
|
config = c;
|
||||||
|
profiler = new TerraProfiler(w);
|
||||||
|
|
||||||
ConfigPackTemplate template = config.getTemplate();
|
ConfigPackTemplate template = config.getTemplate();
|
||||||
|
|
||||||
@@ -71,4 +73,8 @@ public class TerraWorld {
|
|||||||
public boolean isSafe() {
|
public boolean isSafe() {
|
||||||
return safe;
|
return safe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TerraProfiler getProfiler() {
|
||||||
|
return profiler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.dfsek.terra.command.profile;
|
package com.dfsek.terra.command.profile;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.Terra;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -18,8 +18,8 @@ public class QueryCommand extends WorldCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
WorldProfiler profile = TerraProfiler.fromWorld(w);
|
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||||
sender.sendMessage(profile.getResultsFormatted());
|
sender.sendMessage(profile.getResultsFormatted());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.dfsek.terra.command.profile;
|
package com.dfsek.terra.command.profile;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -20,7 +20,7 @@ public class ResetCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
WorldProfiler profile = TerraProfiler.fromWorld(world);
|
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||||
profile.reset();
|
profile.reset();
|
||||||
LangUtil.send("command.profile.reset", sender);
|
LangUtil.send("command.profile.reset", sender);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.dfsek.terra.command.profile;
|
package com.dfsek.terra.command.profile;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -20,7 +20,7 @@ public class StartCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
WorldProfiler profile = TerraProfiler.fromWorld(world);
|
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||||
profile.setProfiling(true);
|
profile.setProfiling(true);
|
||||||
LangUtil.send("command.profile.start", sender);
|
LangUtil.send("command.profile.start", sender);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.dfsek.terra.command.profile;
|
package com.dfsek.terra.command.profile;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -20,7 +20,7 @@ public class StopCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
WorldProfiler profile = TerraProfiler.fromWorld(world);
|
WorldProfiler profile = ((Terra) getMain()).getWorld(world).getProfiler();
|
||||||
profile.setProfiling(false);
|
profile.setProfiling(false);
|
||||||
LangUtil.send("command.profile.stop", sender);
|
LangUtil.send("command.profile.stop", sender);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.generation;
|
package com.dfsek.terra.generation;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
@@ -98,7 +97,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
org.polydev.gaea.biome.BiomeGrid grid = getBiomeGrid(world);
|
org.polydev.gaea.biome.BiomeGrid grid = getBiomeGrid(world);
|
||||||
|
|
||||||
ElevationInterpolator elevationInterpolator;
|
ElevationInterpolator elevationInterpolator;
|
||||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("ElevationTime")) {
|
try(ProfileFuture ignore = tw.getProfiler().measure("ElevationTime")) {
|
||||||
elevationInterpolator = new ElevationInterpolator(chunkX, chunkZ, tw.getGrid());
|
elevationInterpolator = new ElevationInterpolator(chunkX, chunkZ, tw.getGrid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
@@ -36,9 +35,9 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
|
|
||||||
Random random = PopulationUtil.getRandom(chunk);
|
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
|
try(ProfileFuture ignored = tw.getProfiler().measure("CaveTime")) {
|
||||||
|
Random random = PopulationUtil.getRandom(chunk);
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
ConfigPack config = tw.getConfig();
|
ConfigPack config = tw.getConfig();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||||
@@ -32,8 +31,8 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
|
try(ProfileFuture ignored = tw.getProfiler().measure("FloraTime")) {
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
Map<Vector2, List<FloraLayer>> layers = new HashMap<>();
|
Map<Vector2, List<FloraLayer>> layers = new HashMap<>();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
@@ -28,8 +27,8 @@ public class OrePopulator extends GaeaBlockPopulator {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
|
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
|
try(ProfileFuture ignored = tw.getProfiler().measure("OreTime")) {
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
for(int cx = -1; cx <= 1; cx++) {
|
for(int cx = -1; cx <= 1; cx++) {
|
||||||
for(int cz = -1; cz <= 1; cz++) {
|
for(int cz = -1; cz <= 1; cz++) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||||
@@ -38,11 +37,11 @@ public class StructurePopulator extends BlockPopulator {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("StructureTime")) {
|
TerraWorld tw = main.getWorld(world);
|
||||||
|
try(ProfileFuture ignored = tw.getProfiler().measure("StructureTime")) {
|
||||||
Random random = PopulationUtil.getRandom(chunk);
|
Random random = PopulationUtil.getRandom(chunk);
|
||||||
int cx = (chunk.getX() << 4);
|
int cx = (chunk.getX() << 4);
|
||||||
int cz = (chunk.getZ() << 4);
|
int cz = (chunk.getZ() << 4);
|
||||||
TerraWorld tw = main.getWorld(world);
|
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
ConfigPack config = tw.getConfig();
|
ConfigPack config = tw.getConfig();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||||
@@ -32,8 +31,8 @@ public class TreePopulator extends GaeaBlockPopulator {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("TreeTime")) {
|
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
|
try(ProfileFuture ignored = tw.getProfiler().measure("TreeTime")) {
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
for(int x = 0; x < 16; x += 2) {
|
for(int x = 0; x < 16; x += 2) {
|
||||||
|
|||||||
Reference in new issue
Block a user