diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/core/SystemInfo.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/core/SystemInfo.java')
| -rw-r--r-- | NET/worlds/core/SystemInfo.java | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/NET/worlds/core/SystemInfo.java b/NET/worlds/core/SystemInfo.java new file mode 100644 index 0000000..ceb2a7f --- /dev/null +++ b/NET/worlds/core/SystemInfo.java @@ -0,0 +1,114 @@ +package NET.worlds.core; + +import NET.worlds.console.Main; +import NET.worlds.console.MainCallback; +import NET.worlds.console.MainTerminalCallback; +import java.io.PrintStream; + +public class SystemInfo implements MainCallback, MainTerminalCallback { + private static SystemInfo instance = new SystemInfo(); + private long _lastFrame = 0L; + private long _lastReport = 0L; + private long _min; + private long _max; + private long _avg; + private long _avgCount = 0L; + + private SystemInfo() { + Main.register(this); + } + + @Override + public void mainCallback() { + long curTime = Std.getFastTime(); + long frameTime = curTime - this._lastFrame; + if (frameTime < this._min) { + this._min = frameTime; + } + + if (frameTime > this._max) { + this._max = frameTime; + } + + this._avg += frameTime; + this._avgCount++; + if (curTime - this._lastReport > 300000L) { + if (this._lastFrame != 0L) { + System.out.println(logTime() + "Frame rate report:" + this._min + "/" + this._avg / this._avgCount + "/" + this._max); + } + + this._min = 10000L; + this._max = 0L; + this._avg = 0L; + this._avgCount = 0L; + this._lastReport = curTime; + } + + this._lastFrame = curTime; + } + + @Override + public void terminalCallback() { + Main.unregister(this); + if (this._avgCount != 0L) { + System.out.println(logTime() + "Frame rate report:" + this._min + "/" + this._avg / this._avgCount + "/" + this._max); + } + } + + public static void Record(PrintStream out) { + out.println("DISK REPORT:"); + recordPath(out, "Windows SYSTEM path", GetSystemDirectory()); + recordPath(out, "Current Working Directory", GetCurrentDirectory()); + out.println(""); + out.println("JAVA MEMORY:"); + out.println(logTime() + "\t Free memory: " + Runtime.getRuntime().freeMemory()); + out.println(logTime() + "\tTotal memory: " + Runtime.getRuntime().totalMemory()); + out.println(""); + out.println("WINDOWS MEMORY:"); + out.println(logTime() + "\tTotal Physical Memory: " + GetTotalPhysicalMemory()); + out.println(logTime() + "\tAvail Physical Memory: " + GetAvailPhysicalMemory()); + out.println(logTime() + "\t Total Paged Memory: " + GetTotalPagedMemory()); + out.println(logTime() + "\t Avail Paged Memory: " + GetAvailPagedMemory()); + out.println(""); + out.println(logTime() + "Java Properties: " + System.getProperties()); + out.println(logTime() + "Number of CPUs: " + GetNumberOfProcessors()); + out.println(logTime() + "Processor Type: " + GetProcessorType()); + out.println(logTime() + "Platform Type: " + GetPlatformID()); + } + + private static void recordPath(PrintStream out, String comment, String path) { + out.println(logTime() + comment + ": " + path); + if (path != null) { + String drive = path.substring(0, 2); + out.println(logTime() + "\tFree disk space (" + drive + "): " + GetDiskFreeSpace(drive + "\\") + " KB"); + } + } + + public static String logTime() { + return "[" + Std.getRealTime() + "] "; + } + + public static native int GetDiskFreeSpace(String var0); + + public static int GetDiskFreeSpace() { + return GetDiskFreeSpace(null); + } + + public static native String GetSystemDirectory(); + + public static native String GetCurrentDirectory(); + + public static native int GetTotalPhysicalMemory(); + + public static native int GetAvailPhysicalMemory(); + + public static native int GetTotalPagedMemory(); + + public static native int GetAvailPagedMemory(); + + public static native String GetPlatformID(); + + public static native int GetNumberOfProcessors(); + + public static native String GetProcessorType(); +} |