mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-22 13:09:53 +00:00
Fixed tick report using the wrong data array.
Remove the dump command for now.
This commit is contained in:
1 parent
7a3c579fa0
commit
438171bf9d
6 files changed
+36
-170
No files matched your search
@@ -1,153 +0,0 @@
|
||||
package mcp.mobius.opis.commands.server;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import mcp.mobius.opis.modOpis;
|
||||
import mcp.mobius.opis.commands.IOpisCommand;
|
||||
import mcp.mobius.opis.data.holders.stats.StatsMod;
|
||||
import mcp.mobius.opis.data.holders.stats.StatsTileEntity;
|
||||
import mcp.mobius.opis.data.managers.TileEntityManager;
|
||||
import mcp.mobius.opis.server.PlayerTracker;
|
||||
import mcp.mobius.opis.tools.ModIdentification;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.MemoryConnection;
|
||||
import net.minecraft.network.packet.Packet3Chat;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
public class CommandDataDump extends CommandBase implements IOpisCommand {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "opis_dump";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandNameOpis() {
|
||||
return this.getCommandName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
ArrayList<StatsMod> modStats = TileEntityManager.getModStats();
|
||||
try {
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter("mods.csv"));
|
||||
|
||||
out.write(String.format("modid,ntes,mean,geommean,variance,min,max,sum,median\n"));
|
||||
|
||||
for (StatsMod stat: modStats)
|
||||
out.write(String.format("%s,%d,%f,%f,%f,%f,%f,%f,%f\n", stat.getModID(),
|
||||
stat.dstat.getN(),
|
||||
stat.dstat.getMean(),
|
||||
stat.dstat.getGeometricMean(),
|
||||
stat.dstat.getVariance(),
|
||||
stat.dstat.getMin(),
|
||||
stat.dstat.getMax(),
|
||||
stat.dstat.getSum(),
|
||||
stat.getMedian()));
|
||||
out.close();
|
||||
if (icommandsender instanceof DedicatedServer){}
|
||||
//PacketDispatcher.sendPacketToServer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oMods datadump done.")));
|
||||
else
|
||||
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oMods datadump done.")), (Player)icommandsender);
|
||||
|
||||
} catch (IOException e) {
|
||||
modOpis.log.log(Level.WARNING, "Failed to write mods data");
|
||||
|
||||
if (icommandsender instanceof DedicatedServer){}
|
||||
//PacketDispatcher.sendPacketToServer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oMods datadump failed.")));
|
||||
else
|
||||
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oMods datadump failed.")), (Player)icommandsender);
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int nentities = TileEntityManager.stats.size();
|
||||
ArrayList<StatsTileEntity> entStats = TileEntityManager.getTopEntities(nentities);
|
||||
try {
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter("tileentities.csv"));
|
||||
|
||||
out.write(String.format("name,mod,dim,x,y,z,chunkX,chunkZ,npoints,mean,geommean,variance,min,max,sum,median\n"));
|
||||
|
||||
for (StatsTileEntity stat: entStats){
|
||||
|
||||
ItemStack is;
|
||||
String name = String.format("te.%d.%d", stat.getID(), stat.getMeta());
|
||||
String modID = "<Unknown>";
|
||||
|
||||
try{
|
||||
is = new ItemStack(stat.getID(), 1, stat.getMeta());
|
||||
name = is.getDisplayName();
|
||||
modID = ModIdentification.idFromStack(is);
|
||||
} catch (Exception e) { }
|
||||
|
||||
out.write(String.format("%s,%s,%d,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f\n", name,
|
||||
modID,
|
||||
stat.getCoordinates().dim,
|
||||
stat.getCoordinates().x,
|
||||
stat.getCoordinates().y,
|
||||
stat.getCoordinates().z,
|
||||
stat.getChunk().chunkX,
|
||||
stat.getChunk().chunkZ,
|
||||
stat.dstat.getN(),
|
||||
stat.dstat.getMean(),
|
||||
stat.dstat.getGeometricMean(),
|
||||
stat.dstat.getVariance(),
|
||||
stat.dstat.getMin(),
|
||||
stat.dstat.getMax(),
|
||||
stat.dstat.getSum(),
|
||||
stat.getMedian()));
|
||||
}
|
||||
out.close();
|
||||
|
||||
if (icommandsender instanceof DedicatedServer){}
|
||||
//PacketDispatcher.sendPacketToServer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oTileEntities datadump done.")));
|
||||
else
|
||||
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oTileEntities datadump done.")), (Player)icommandsender);
|
||||
|
||||
} catch (IOException e) {
|
||||
modOpis.log.log(Level.WARNING, "Failed to write tile entities data");
|
||||
if (icommandsender instanceof DedicatedServer){}
|
||||
//PacketDispatcher.sendPacketToServer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oTileEntities datadump failed.")));
|
||||
else
|
||||
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText("\u00A7oTileEntities datadump failed.")), (Player)icommandsender);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender sender)
|
||||
{
|
||||
if (sender instanceof DedicatedServer) return true;
|
||||
if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
|
||||
if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true;
|
||||
return PlayerTracker.instance().isPrivileged(((EntityPlayerMP)sender).username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Dumps chunks and TEs data to csv.";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,8 +46,6 @@ public class CommandHelp extends CommandBase implements IOpisCommand {
|
||||
new CommandTimingEntities(),
|
||||
new CommandAmountEntities(),
|
||||
|
||||
new CommandDataDump(),
|
||||
|
||||
new CommandKill(),
|
||||
new CommandKillAll(),
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import mcp.mobius.opis.data.holders.basetypes.CoordinatesChunk;
|
||||
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
|
||||
public abstract class StatAbstract implements Comparable, ISerializable{
|
||||
public DescriptiveStatistics dstat = new DescriptiveStatistics();
|
||||
protected DescriptiveStatistics dstat = new DescriptiveStatistics();
|
||||
public Long dataPoints = 0L;
|
||||
protected Double geomMean = null;
|
||||
protected Double dataSum = null;
|
||||
@@ -18,13 +18,24 @@ public abstract class StatAbstract implements Comparable, ISerializable{
|
||||
protected CoordinatesChunk chunk = new CoordinatesChunk(0,0,0);
|
||||
protected String name;
|
||||
|
||||
/*
|
||||
public StatAbstract(){
|
||||
dstat = new DescriptiveStatistics();
|
||||
}
|
||||
|
||||
public StatAbstract(int points){
|
||||
dstat = new DescriptiveStatistics(points);
|
||||
}
|
||||
*/
|
||||
|
||||
public void addMeasure(long timing){
|
||||
dstat.addValue((double)timing/1000.0);
|
||||
//this.dstat.addValue((double)timing/1000.0);
|
||||
this.dstat.addValue((double)timing/1000.);
|
||||
dataPoints += 1;
|
||||
}
|
||||
|
||||
public void addMeasure(double timing){
|
||||
dstat.addValue(timing);
|
||||
this.dstat.addValue(timing);
|
||||
dataPoints += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,14 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
|
||||
public class StatsTick extends StatAbstract {
|
||||
|
||||
public DescriptiveStatistics dstat = new DescriptiveStatistics(30);
|
||||
public StatsTick(){
|
||||
this.dstat = new DescriptiveStatistics(20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(DataOutputStream stream) throws IOException {
|
||||
stream.writeDouble(this.getGeometricMean());
|
||||
//stream.writeDouble(this.getGeometricMean());
|
||||
stream.writeDouble(this.dstat.getGeometricMean());
|
||||
}
|
||||
|
||||
public static StatsTick readFromStream(DataInputStream stream) throws IOException {
|
||||
|
||||
@@ -15,7 +15,6 @@ import mcp.mobius.opis.commands.server.CommandAddPrivileged;
|
||||
import mcp.mobius.opis.commands.server.CommandAmountEntities;
|
||||
import mcp.mobius.opis.commands.server.CommandChunkDump;
|
||||
import mcp.mobius.opis.commands.server.CommandChunkList;
|
||||
import mcp.mobius.opis.commands.server.CommandDataDump;
|
||||
import mcp.mobius.opis.commands.server.CommandEntityCreate;
|
||||
import mcp.mobius.opis.commands.server.CommandFrequency;
|
||||
import mcp.mobius.opis.commands.server.CommandHandler;
|
||||
@@ -63,7 +62,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@Mod(modid="Opis", name="Opis", version="1.1.3a_alpha")
|
||||
@Mod(modid="Opis", name="Opis", version="1.2.0_dev2_alpha")
|
||||
@NetworkMod(channels={"Opis", "Opis_Chunk"},clientSideRequired=false, serverSideRequired=false, connectionHandler=OpisConnectionHandler.class, packetHandler=OpisPacketHandler.class)
|
||||
|
||||
public class modOpis {
|
||||
@@ -136,7 +135,6 @@ public class modOpis {
|
||||
event.registerServerCommand(new CommandStop());
|
||||
event.registerServerCommand(new CommandTimingTileEntities());
|
||||
event.registerServerCommand(new CommandMeanModTime());
|
||||
event.registerServerCommand(new CommandDataDump());
|
||||
event.registerServerCommand(new CommandTicks());
|
||||
event.registerServerCommand(new CommandTimingEntities());
|
||||
event.registerServerCommand(new CommandAmountEntities());
|
||||
|
||||
@@ -44,7 +44,8 @@ public class OpisServerTickHandler implements ITickHandler {
|
||||
public long profilerUpdateTickCounter = 0;
|
||||
public long clientUpdateTickCounter = 0;
|
||||
public int profilerRunningTicks;
|
||||
public long timeLastUpdate = System.nanoTime();
|
||||
public long timer500 = System.nanoTime();
|
||||
public long timer1000 = System.nanoTime();
|
||||
|
||||
public static OpisServerTickHandler instance;
|
||||
|
||||
@@ -59,17 +60,25 @@ public class OpisServerTickHandler implements ITickHandler {
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
if(type.contains(TickType.SERVER)){
|
||||
|
||||
if (System.nanoTime() - timeLastUpdate > 1000000000){
|
||||
timeLastUpdate = System.nanoTime();
|
||||
|
||||
/*
|
||||
if (System.nanoTime() - timer500 > 500000000){
|
||||
timer500 = System.nanoTime();
|
||||
|
||||
for (Player player : PlayerTracker.instance().playersSwing){
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.VALUE_TIMING_TICK, TickProfiler.instance().stats), player);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (System.nanoTime() - timer1000 > 1000000000){
|
||||
timer1000 = System.nanoTime();
|
||||
|
||||
for (Player player : PlayerTracker.instance().playersSwing){
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.VALUE_AMOUNT_UPLOAD, new SerialLong(PacketProfiler.instance().dataSizeOut)), player);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.VALUE_AMOUNT_DOWNLOAD, new SerialLong(PacketProfiler.instance().dataSizeIn)), player);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.VALUE_TIMING_TICK, TickProfiler.instance().stats), player);
|
||||
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.STATUS_RUN_UPDATE, new SerialInt(profilerRunningTicks)), player);
|
||||
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataValue.create(DataReq.VALUE_TIMING_TICK, TickProfiler.instance().stats), player);
|
||||
PacketDispatcher.sendPacketToPlayer(Packet_DataList.create(DataReq.LIST_PLAYERS, EntityManager.getAllPlayers()), player);
|
||||
}
|
||||
PacketProfiler.instance().dataSizeOut = 0L;
|
||||
|
||||
Reference in new issue
Block a user