Skip to content

Commit

Permalink
Better per-object stats names
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Feb 7, 2013
1 parent 4c56aeb commit d7831e6
Showing 1 changed file with 13 additions and 2 deletions.
Expand Up @@ -11,6 +11,8 @@

import me.nallar.tickthreading.util.MappingUtil;
import me.nallar.tickthreading.util.TableFormatter;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import org.cliffc.high_scale_lib.NonBlockingHashMap;

public class EntityTickProfiler {
Expand Down Expand Up @@ -58,10 +60,10 @@ public TableFormatter writeData(TableFormatter tf) {
final List<Object> sortedSingleKeysByTime = Ordering.natural().reverse().onResultOf(Functions.forMap(singleTime)).immutableSortedCopy(singleTime.keySet());
tf
.heading("Obj")
.heading("Max Time(ms)");
.heading("Max Time");
for (int i = 0; i < 5 && i < sortedSingleKeysByTime.size(); i++) {
tf
.row(sortedSingleKeysByTime.get(i).toString().substring(0, 48))
.row(niceName(sortedSingleKeysByTime.get(i)))
.row(singleTime.get(sortedSingleKeysByTime.get(i)) / 1000000d);
}
tf.finishTable();
Expand Down Expand Up @@ -98,6 +100,15 @@ public TableFormatter writeData(TableFormatter tf) {
return tf;
}

private static Object niceName(Object o) {
if (o instanceof TileEntity) {
return niceName(o.getClass()) + ' ' + ((TileEntity) o).xCoord + ',' + ((TileEntity) o).yCoord + ',' + ((TileEntity) o).zCoord;
} else if (o instanceof Entity) {
return niceName(o.getClass()) + ' ' + (int) ((Entity) o).posX + ',' + (int) ((Entity) o).posY + ',' + (int) ((Entity) o).posZ;
}
return o.toString().substring(0, 48);
}

private static String niceName(Class<?> clazz) {
String name = MappingUtil.debobfuscate(clazz.getName());
if (name.contains(".")) {
Expand Down

0 comments on commit d7831e6

Please sign in to comment.