diff --git a/src/client/GameRunner.ts b/src/client/GameRunner.ts index e739fb031..512ddffde 100644 --- a/src/client/GameRunner.ts +++ b/src/client/GameRunner.ts @@ -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) diff --git a/src/client/graphics/GameRenderer.ts b/src/client/graphics/GameRenderer.ts index e3b0d1f18..513ee2c48 100644 --- a/src/client/graphics/GameRenderer.ts +++ b/src/client/graphics/GameRenderer.ts @@ -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() {