Total Ram info inside DebugInfo command (#6507)

* add total ram available info to DebugInfo command

* remove unused import
This commit is contained in:
IThundxr 2024-07-15 09:07:52 -04:00 committed by GitHub
parent 398eb64880
commit 1722d4dda0
Failed to generate hash of commit

View file

@ -26,6 +26,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.forgespi.language.IModInfo;
import oshi.SystemInfo;
/**
* Allows for providing easily accessible debugging information.
@ -86,6 +87,7 @@ public class DebugInformation {
.put("Java Version", SystemReportAccessor.getJAVA_VERSION())
.put("JVM Flags", getMcSystemInfo("JVM Flags"))
.put("Memory", () -> getMcSystemInfo("Memory"))
.put("Total Memory", getTotalRam())
.put("CPU", getCpuInfo())
.putAll(listAllGraphicsCards())
.buildTo(DebugInformation::registerBothInfo);
@ -129,6 +131,13 @@ public class DebugInformation {
return cards.isEmpty() ? List.of(new InfoEntry("Graphics cards", "none")) : cards;
}
public static String getTotalRam() {
long availableMemory = new SystemInfo().getHardware().getMemory().getAvailable();
long totalMemory = new SystemInfo().getHardware().getMemory().getTotal();
long usedMemory = totalMemory - availableMemory;
return String.format("%s bytes (%s MiB) / %s bytes (%s MiB)", usedMemory, usedMemory / 1049000, totalMemory, totalMemory / 1049000);
}
public static String getCpuInfo() {
String name = tryTrim(getMcSystemInfo("Processor Name"));
String freq = getMcSystemInfo("Frequency (GHz)");