mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-21 20:52:14 +00:00
Directory structure for ForgeGradle
This commit is contained in:
1 parent
3d8319dc6b
commit
04764c83c9
214 files changed
+104
-6
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package mcp.mobius.opis.data.profilers;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
|
||||
public class Clock {
|
||||
|
||||
public interface IClock{
|
||||
void start();
|
||||
void stop();
|
||||
long getDelta();
|
||||
}
|
||||
|
||||
public static ThreadMXBean threadMX = ManagementFactory.getThreadMXBean();
|
||||
//public static boolean canThreadCPU = threadMX.isCurrentThreadCpuTimeSupported();
|
||||
public static boolean canThreadCPU = false;
|
||||
|
||||
public class ClockMX implements IClock{
|
||||
public long startTime = 0;
|
||||
public long timeDelta = 0;
|
||||
public void start(){this.startTime = threadMX.getCurrentThreadCpuTime();}
|
||||
public void stop() {this.timeDelta = threadMX.getCurrentThreadCpuTime() - this.startTime;}
|
||||
public long getDelta() {return this.timeDelta;}
|
||||
}
|
||||
|
||||
public class ClockNano implements IClock{
|
||||
public long startTime = 0;
|
||||
public long timeDelta = 0;
|
||||
public void start(){this.startTime = System.nanoTime();}
|
||||
public void stop() {this.timeDelta = System.nanoTime() - this.startTime;}
|
||||
public long getDelta() {return this.timeDelta;}
|
||||
}
|
||||
|
||||
public static IClock getNewClock(){
|
||||
if (Clock.canThreadCPU)
|
||||
return new Clock().new ClockMX();
|
||||
else
|
||||
return new Clock().new ClockNano();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user