57 lines
1,004 B
Java
57 lines
1,004 B
Java
![]() |
package game.util;
|
||
|
|
||
|
import game.window.WCF;
|
||
|
|
||
|
public enum PerfSection {
|
||
|
TIMING("Timing"),
|
||
|
INPUT("Input"),
|
||
|
TICK("Tick"),
|
||
|
UPDATE("Update"),
|
||
|
RENDER("Render"),
|
||
|
GUI("Gui"),
|
||
|
REST("Rest"),
|
||
|
SWAP("Swap"),
|
||
|
EVENTS("Events"),
|
||
|
WAIT("Wait");
|
||
|
|
||
|
private static PerfSection section;
|
||
|
private static int swap;
|
||
|
private static long start;
|
||
|
private static long total;
|
||
|
|
||
|
private final String name;
|
||
|
|
||
|
private long time;
|
||
|
private long[] last = new long[2];
|
||
|
|
||
|
private PerfSection(String name) {
|
||
|
this.name = name;
|
||
|
}
|
||
|
|
||
|
public void enter() {
|
||
|
this.time = WCF.getTime();
|
||
|
if(section != null)
|
||
|
section.last[swap] = section.time = this.time - section.time;
|
||
|
section = this;
|
||
|
}
|
||
|
|
||
|
public String getName() {
|
||
|
return this.name;
|
||
|
}
|
||
|
|
||
|
public long getLast() {
|
||
|
return this.last[swap ^ 1];
|
||
|
}
|
||
|
|
||
|
public static void swap() {
|
||
|
long current = WCF.getTime();
|
||
|
total = current - start;
|
||
|
start = current;
|
||
|
swap ^= 1;
|
||
|
}
|
||
|
|
||
|
public static long getTotal(boolean wait) {
|
||
|
return total - (wait ? 0L : WAIT.getLast());
|
||
|
}
|
||
|
}
|