Skip to content

Commit

Permalink
Re-add simulation time warn logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Oct 9, 2023
1 parent b179f07 commit 79d2673
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class Simulation {


public Simulation(World world) {
calculatedStates = keptStates = restStates = 0;
long startTimeMs = System.currentTimeMillis();
this.world = world;
this.startTickID = ((ServerChronoState)ChronoState.getState(world)).getServerTickID();

Expand Down Expand Up @@ -61,9 +63,16 @@ public Simulation(World world) {
new MRSSyncPacket(stock, stock.positions).sendToObserving(stock);
}
}

long totalTimeMs = System.currentTimeMillis() - startTimeMs;
if (totalTimeMs > Config.ConfigDebug.physicsWarnTotalThresholdMs) {
ImmersiveRailroading.warn("Calculating Immersive Railroading Physics took %sms (%s, %s, %s)", totalTimeMs, calculatedStates, restStates, keptStates);
}
}

public void simulateTick(int iteration) {
long startTimeMs = System.currentTimeMillis();

int tickID = startTickID + iteration;

Map<UUID, SimulationState> stateMap = stateMaps.get(iteration);
Expand Down Expand Up @@ -337,6 +346,11 @@ This can happen when a piece of stock is marked dirty (discard existing states e

// calculate new velocities
Consist.iterate(stateMap, nextStateMap, blocksAlreadyBroken);

long totalTimeMs = System.currentTimeMillis() - startTimeMs;
if (totalTimeMs > Config.ConfigDebug.physicsWarnThresholdMs) {
ImmersiveRailroading.warn("Calculating Immersive Railroading Physics Iteration took %sms (%s, %s, %s)", totalTimeMs, calculatedStates, restStates, keptStates);
}
}


Expand Down

0 comments on commit 79d2673

Please sign in to comment.