blob: ceb2a7f29ddfc932cb72040c40d7a0ebf67ec632 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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();
}
|