add profiler calls for the biggest performance hogs. Also numbers bad for survival go away no

This commit is contained in:
Ellpeck 2018-10-26 20:25:21 +02:00
parent cd61b2a8f1
commit 57af7e50c1
5 changed files with 23 additions and 13 deletions

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.aura.chunk; package de.ellpeck.naturesaura.aura.chunk;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.aura.Capabilities; import de.ellpeck.naturesaura.aura.Capabilities;
import de.ellpeck.naturesaura.aura.chunk.effect.GrassDieEffect; import de.ellpeck.naturesaura.aura.chunk.effect.GrassDieEffect;
import de.ellpeck.naturesaura.aura.chunk.effect.IDrainSpotEffect; import de.ellpeck.naturesaura.aura.chunk.effect.IDrainSpotEffect;
@ -45,6 +46,7 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
} }
public static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, MutableInt> consumer) { public static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, MutableInt> consumer) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getSpotsInArea");
for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) { for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) {
for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) { for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) {
Chunk chunk = world.getChunk(x, z); Chunk chunk = world.getChunk(x, z);
@ -54,6 +56,7 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
} }
} }
} }
world.profiler.endSection();
} }
public static int getAuraInArea(World world, BlockPos pos, int radius) { public static int getAuraInArea(World world, BlockPos pos, int radius) {

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.aura.chunk.effect; package de.ellpeck.naturesaura.aura.chunk.effect;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.*; import net.minecraft.block.*;
@ -14,6 +15,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
public class GrassDieEffect implements IDrainSpotEffect { public class GrassDieEffect implements IDrainSpotEffect {
@Override @Override
public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) { public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":GrassDieEffect");
if (spot.intValue() < 0) { if (spot.intValue() < 0) {
int aura = AuraChunk.getAuraInArea(world, pos, 25); int aura = AuraChunk.getAuraInArea(world, pos, 25);
if (aura < 0) { if (aura < 0) {
@ -47,5 +49,6 @@ public class GrassDieEffect implements IDrainSpotEffect {
} }
} }
} }
world.profiler.endSection();
} }
} }

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.aura.chunk.effect; package de.ellpeck.naturesaura.aura.chunk.effect;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.aura.Capabilities; import de.ellpeck.naturesaura.aura.Capabilities;
import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk;
import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable; import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable;
@ -16,6 +17,7 @@ import java.util.List;
public class ReplenishingEffect implements IDrainSpotEffect { public class ReplenishingEffect implements IDrainSpotEffect {
@Override @Override
public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) { public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":ReplenishingEffect");
int amount = spot.intValue(); int amount = spot.intValue();
if (amount < 0) { if (amount < 0) {
List<ISpotDrainable> tiles = new ArrayList<>(); List<ISpotDrainable> tiles = new ArrayList<>();
@ -39,5 +41,6 @@ public class ReplenishingEffect implements IDrainSpotEffect {
} }
} }
} }
world.profiler.endSection();
} }
} }

View file

@ -47,20 +47,19 @@ public class ClientEvents {
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " "; String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
List<String> left = event.getLeft(); List<String> left = event.getLeft();
left.add(""); left.add("");
left.add(prefix + "PartScrn: " + ParticleHandler.getParticleAmount()); left.add(prefix + "Particles: " + ParticleHandler.getParticleAmount());
boolean adv = mc.gameSettings.showDebugProfilerChart; if (mc.player.capabilities.isCreativeMode) {
if (adv) left.add(prefix + "Aura:");
left.add(prefix + "DrainSpots:");
MutableInt amount = new MutableInt(AuraChunk.DEFAULT_AURA); MutableInt amount = new MutableInt(AuraChunk.DEFAULT_AURA);
MutableInt spots = new MutableInt(); MutableInt spots = new MutableInt();
AuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 15, ((blockPos, drainSpot) -> { AuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 15, ((blockPos, drainSpot) -> {
spots.increment(); spots.increment();
amount.add(drainSpot.intValue()); amount.add(drainSpot.intValue());
if (adv) left.add(prefix + drainSpot.intValue() + " @ " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ());
left.add(prefix + drainSpot.intValue() + " @ " + blockPos.getX()+" "+blockPos.getY()+" "+blockPos.getZ());
})); }));
left.add(prefix + "Aura: " + amount.intValue() + " in " + spots.intValue() + " spots"); left.add(prefix + "Total: " + amount.intValue() + " in " + spots.intValue() + " spots");
}
} }
} }

View file

@ -28,6 +28,7 @@ public class CommonEvents {
public void onWorldTick(TickEvent.WorldTickEvent event) { public void onWorldTick(TickEvent.WorldTickEvent event) {
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) { if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
if (event.world.getTotalWorldTime() % 20 == 0) { if (event.world.getTotalWorldTime() % 20 == 0) {
event.world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldTick");
Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((WorldServer) event.world).getPlayerChunkMap().getChunkIterator()); Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((WorldServer) event.world).getPlayerChunkMap().getChunkIterator());
while (chunks.hasNext()) { while (chunks.hasNext()) {
Chunk chunk = chunks.next(); Chunk chunk = chunks.next();
@ -36,6 +37,7 @@ public class CommonEvents {
auraChunk.update(); auraChunk.update();
} }
} }
event.world.profiler.endSection();
} }
} }
} }