mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 13:29:09 +00:00
warn if tick or render takes to long
This commit is contained in:
@@ -180,7 +180,12 @@ export class GameRunner {
|
||||
this.isProcessingTurn = true
|
||||
this.gs.addExecution(...this.executor.createExecs(this.turns[this.currTurn]))
|
||||
try {
|
||||
const start = performance.now()
|
||||
this.gs.executeNextTick()
|
||||
const duration = performance.now() - start
|
||||
if (duration > 100) {
|
||||
console.warn(`tick ${this.gs.ticks() - 1} took ${duration}ms to execute`)
|
||||
}
|
||||
} catch (error) {
|
||||
const errorText = `Error: ${error.message}\nStack: ${error.stack}`;
|
||||
consolex.error(errorText)
|
||||
|
||||
@@ -116,6 +116,7 @@ export class GameRenderer {
|
||||
}
|
||||
|
||||
renderGame() {
|
||||
const start = performance.now()
|
||||
// Set background
|
||||
this.context.fillStyle = this.game.config().theme().backgroundColor().toHex();
|
||||
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
@@ -140,6 +141,11 @@ export class GameRenderer {
|
||||
})
|
||||
|
||||
requestAnimationFrame(() => this.renderGame());
|
||||
|
||||
const duration = performance.now() - start
|
||||
if (duration > 10) {
|
||||
console.warn(`tick ${this.game.ticks()} took ${duration}ms to render frame`)
|
||||
}
|
||||
}
|
||||
|
||||
tick() {
|
||||
|
||||
Reference in New Issue
Block a user