Skip to content

Commit

Permalink
Plot Entities, TileEntities and Chunks counts wiht metrics.
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed May 29, 2013
1 parent 5f7dbe9 commit 6f1e017
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions src/common/me/nallar/tickprofiler/reporting/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
import cpw.mods.fml.relauncher.Side;
import me.nallar.tickprofiler.Log;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.DimensionManager;

/**
* <p>
Expand Down Expand Up @@ -146,8 +149,14 @@ public Metrics(final String modname, final String modversion) {
debug = configuration.get(Configuration.CATEGORY_GENERAL, "debug",
false, "Set to true for verbose debug").getBoolean(false);
configuration.save();
if (start()) {
Log.info("Started TickProfiler metrics reporting. This can be disabled in PluginMetrics.cfg");
if (!isOptOut()) {
Graph graph = createGraph("Perf");
graph.addPlotter(new TileEntityPlotter());
graph.addPlotter(new EntityPlotter());
graph.addPlotter(new ChunkPlotter());
if (start()) {
Log.info("Started TickProfiler metrics reporting. This can be disabled in PluginMetrics.cfg");
}
}
}

Expand Down Expand Up @@ -674,4 +683,49 @@ public boolean equals(final Object object) {
&& plotter.getValue() == getValue();
}
}

private static class TileEntityPlotter extends Plotter {
public TileEntityPlotter() {
super("TileEntities");
}

@Override
public int getValue() {
int i = 0;
for (World world : DimensionManager.getWorlds()) {
i += world.loadedTileEntityList.size();
}
return i;
}
}

private static class EntityPlotter extends Plotter {
public EntityPlotter() {
super("Entities");
}

@Override
public int getValue() {
int i = 0;
for (World world : DimensionManager.getWorlds()) {
i += world.loadedEntityList.size();
}
return i;
}
}

private static class ChunkPlotter extends Plotter {
public ChunkPlotter() {
super("Chunks");
}

@Override
public int getValue() {
int i = 0;
for (World world : DimensionManager.getWorlds()) {
i += world.getChunkProvider().getLoadedChunkCount();
}
return i;
}
}
}

0 comments on commit 6f1e017

Please sign in to comment.