CRITICALLY long intent updates self-identify

This commit is contained in:
dam 2026-05-06 17:57:46 +03:00
parent b4a03da6f1
commit e637f5a2b9
No known key found for this signature in database
GPG key ID: 4AF4E722399663FB

View file

@ -119,8 +119,13 @@ class MajorUpdateWorker {
GameWorld.Pulser.updateAll()
}
GameWorld.tickListeners.forEach { it.tick() }
CombatMovementIntents.requestActiveMeleePressure()
CombatMovementIntents.resolve()
val meleePressureTime = measureMillis {
CombatMovementIntents.requestActiveMeleePressure()
}
val movementResolveTime = measureMillis {
CombatMovementIntents.resolve()
}
notifyIfCombatMovementTooLong(meleePressureTime, movementResolveTime)
sequence.start()
sequence.run()
@ -141,6 +146,36 @@ class MajorUpdateWorker {
}
}
private fun measureMillis(logic: () -> Unit): Long {
val startTime = System.currentTimeMillis()
logic()
return System.currentTimeMillis() - startTime
}
private fun notifyIfCombatMovementTooLong(meleePressureTime: Long, movementResolveTime: Long) {
val totalTime = meleePressureTime + movementResolveTime
if (totalTime >= CRITICAL_COMBAT_MOVEMENT_MS) {
log(
this::class.java,
Log.WARN,
"CRITICALLY long combat movement update - requestActiveMeleePressure took $meleePressureTime ms, resolve took $movementResolveTime ms, total $totalTime ms"
)
} else if (totalTime >= LONG_COMBAT_MOVEMENT_MS) {
log(
this::class.java,
Log.WARN,
"Long combat movement update - requestActiveMeleePressure took $meleePressureTime ms, resolve took $movementResolveTime ms, total $totalTime ms"
)
}
}
companion object {
private const val LONG_COMBAT_MOVEMENT_MS = 30L
private const val CRITICAL_COMBAT_MOVEMENT_MS = 100L
}
fun start() {
if (!started) {
running = true