Updated simulation metrics access.
This commit is contained in:
@@ -15,6 +15,9 @@ import engine.server.MBServerStatics;
|
|||||||
import engine.util.ThreadUtils;
|
import engine.util.ThreadUtils;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
|
||||||
public class MobileFSMManager {
|
public class MobileFSMManager {
|
||||||
|
|
||||||
@@ -23,6 +26,8 @@ public class MobileFSMManager {
|
|||||||
private volatile boolean alive;
|
private volatile boolean alive;
|
||||||
private long timeOfKill = -1;
|
private long timeOfKill = -1;
|
||||||
|
|
||||||
|
public static Duration executionTime;
|
||||||
|
|
||||||
private MobileFSMManager() {
|
private MobileFSMManager() {
|
||||||
|
|
||||||
Runnable worker = new Runnable() {
|
Runnable worker = new Runnable() {
|
||||||
@@ -67,6 +72,7 @@ public class MobileFSMManager {
|
|||||||
//Load zone threshold once.
|
//Load zone threshold once.
|
||||||
|
|
||||||
long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
||||||
|
Instant startTime;
|
||||||
|
|
||||||
while (alive) {
|
while (alive) {
|
||||||
|
|
||||||
@@ -74,6 +80,8 @@ public class MobileFSMManager {
|
|||||||
|
|
||||||
if (System.currentTimeMillis() > mobPulse) {
|
if (System.currentTimeMillis() > mobPulse) {
|
||||||
|
|
||||||
|
startTime = Instant.now();
|
||||||
|
|
||||||
for (Zone zone : ZoneManager.getAllZones()) {
|
for (Zone zone : ZoneManager.getAllZones()) {
|
||||||
|
|
||||||
for (Mob mob : zone.zoneMobSet) {
|
for (Mob mob : zone.zoneMobSet) {
|
||||||
@@ -88,6 +96,7 @@ public class MobileFSMManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.executionTime = Duration.between(startTime, Instant.now());
|
||||||
mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,15 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.ai.MobileFSMManager;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.SimulationManager;
|
import engine.gameManager.SimulationManager;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import java.time.temporal.TemporalUnit;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class HeartbeatCmd extends AbstractDevCmd {
|
public class HeartbeatCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
public HeartbeatCmd() {
|
public HeartbeatCmd() {
|
||||||
@@ -25,19 +29,19 @@ public class HeartbeatCmd extends AbstractDevCmd {
|
|||||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
this.throwbackInfo(pc, "Current Heartbeat : " + SimulationManager.currentHeartBeatDelta + " ms.");
|
this.throwbackInfo(pc, "Heartbeat : " + TimeUnit.NANOSECONDS.toMillis(SimulationManager.HeartbeatDelta.getNano()));
|
||||||
this.throwbackInfo(pc, "Max Heartbeat : " + SimulationManager.HeartbeatDelta + " ms.");
|
this.throwbackInfo(pc, "FSM: " + TimeUnit.NANOSECONDS.toMillis(MobileFSMManager.executionTime.getNano()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Temporarily Changes SubRace";
|
return "Displays simulation metrics";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /subrace mobBaseID";
|
return "' ./heartbeat";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import engine.objects.PlayerCharacter;
|
|||||||
import engine.objects.Runegate;
|
import engine.objects.Runegate;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -39,8 +41,7 @@ public enum SimulationManager {
|
|||||||
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
|
private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE;
|
||||||
private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE;
|
private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE;
|
||||||
|
|
||||||
public static long HeartbeatDelta = 0;
|
public static Duration HeartbeatDelta;
|
||||||
public static long currentHeartBeatDelta = 0;
|
|
||||||
|
|
||||||
private SimulationManager() {
|
private SimulationManager() {
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ public enum SimulationManager {
|
|||||||
* runegates stop working than the game itself!
|
* runegates stop working than the game itself!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
Instant startTime = Instant.now();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((_flightPulseTime != 0)
|
if ((_flightPulseTime != 0)
|
||||||
@@ -112,17 +113,8 @@ public enum SimulationManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
|
|
||||||
long delta = end - start;
|
|
||||||
|
|
||||||
if (delta > SimulationManager.HeartbeatDelta)
|
|
||||||
SimulationManager.HeartbeatDelta = delta;
|
|
||||||
|
|
||||||
SimulationManager.currentHeartBeatDelta = delta;
|
|
||||||
|
|
||||||
|
|
||||||
|
SimulationManager.HeartbeatDelta = Duration.between(startTime, Instant.now());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user