Skip to content

Commit e7a613d

Browse files
committed
Server.getTickUseNano
1 parent 6875f39 commit e7a613d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/cn/nukkit/Server.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public class Server {
140140

141141
private float maxUse = 0;
142142
private float tickUsage;
143+
private long tickUseNano;
143144

144145
private int sendUsageTicker = 0;
145146

@@ -1257,7 +1258,8 @@ private boolean tick() {
12571258
//float use = Math.min(1, (now - tickTime) / 50);
12581259

12591260
float tick = (float) Math.min(20, 1000000000 / Math.max(1000000, ((double) nowNano - tickTimeNano)));
1260-
float use = (float) Math.min(1, ((double) (nowNano - tickTimeNano)) / 50000000);
1261+
this.tickUseNano = nowNano - tickTimeNano; // record the tick time in nano seconds
1262+
float use = (float) Math.min(1, ((double) tickUseNano) / 50000000);
12611263

12621264
if (this.maxTick > tick) {
12631265
this.maxTick = tick;
@@ -1577,6 +1579,10 @@ public float getTickUsageAverage() {
15771579
return tickUsageAverage;
15781580
}
15791581

1582+
public long getTickUseNano() {
1583+
return tickUseNano;
1584+
}
1585+
15801586
private static float getAverage(float[] array) {
15811587
float sum = 0;
15821588
int count = array.length;

0 commit comments

Comments
 (0)