Add 'dynmap dumpmemory' command to dump RP image count, mem use

This commit is contained in:
Mike Primm 2021-08-27 18:40:53 -05:00
parent fc3fc5e18c
commit fa0e87d3c0
2 changed files with 36 additions and 0 deletions

View File

@ -1173,6 +1173,7 @@ public class DynmapCore implements DynmapCommonAPI {
"add-id-for-ip",
"del-id-for-ip",
"webregister",
"dumpmemory",
"help"}));
private static class CommandInfo {
@ -1239,6 +1240,7 @@ public class DynmapCore implements DynmapCommonAPI {
new CommandInfo("dynmap", "webregister", "Start registration process for creating web login account"),
new CommandInfo("dynmap", "webregister", "<player>", "Start registration process for creating web login account for player <player>"),
new CommandInfo("dynmap", "version", "Return version information"),
new CommandInfo("dynmap", "dumpmemory", "Return mempry use information"),
new CommandInfo("dmarker", "", "Manipulate map markers."),
new CommandInfo("dmarker", "add", "<label>", "Add new marker with label <label> at current location (use double-quotes if spaces needed)."),
new CommandInfo("dmarker", "add", "id:<id> <label>", "Add new marker with ID <id> at current location (use double-quotes if spaces needed)."),
@ -1712,6 +1714,9 @@ public class DynmapCore implements DynmapCommonAPI {
else if(c.equals("help")) {
printCommandHelp(sender, cmd, (args.length > 1)?args[1]:"");
}
else if(c.equals("dumpmemory")) {
TexturePack.tallyMemory(sender);
}
else if(c.equals("version")) {
sender.sendMessage("Dynmap version: core=" + this.getDynmapCoreVersion() + ", plugin=" + this.getDynmapPluginVersion());
}

View File

@ -32,6 +32,7 @@ import org.dynmap.DynmapCore;
import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.DynmapCommandSender;
import org.dynmap.exporter.OBJExport;
import org.dynmap.renderer.CustomColorMultiplier;
import org.dynmap.renderer.DynmapBlockState;
@ -3659,4 +3660,34 @@ public class TexturePack {
return id;
}
public static void tallyMemory(DynmapCommandSender sender) {
long packcount = 0;
long packbytecount = 0;
for (String packid : packs.keySet()) {
TexturePack p = packs.get(packid);
long scaledcount = 0;
long scaledbytecount = 0;
for (Integer scale : p.scaled_textures.keySet()) {
TexturePack sp = p.scaled_textures.get(scale);
long bytecount = 0;
long imgcount = 0;
for (int i = 0; i < sp.imgs.length; i++) {
if (sp.imgs[i] != null) {
if (sp.imgs[i].argb != null) {
bytecount += sp.imgs[i].argb.length * 4;
imgcount++;
}
}
}
sender.sendMessage("pack: " + packid + ", scale: " + scale + ", imagecount=" + imgcount + ", bytecount=" + bytecount);
scaledcount += imgcount;
scaledbytecount += bytecount;
}
sender.sendMessage("pack: " + packid + ", total: imagecount=" + scaledcount + ", bytecount=" + scaledbytecount);
packcount += scaledcount;
packbytecount += scaledbytecount;
}
sender.sendMessage("overall total: imagecount=" + packcount + ", bytecount=" + packbytecount + "(" + (packbytecount / 1024.0 / 1024.0) + "Mb)");
}
}