Show entities and time per area while playing in the Game View (#275)
game-maker / gate (push) Successful in 2m35s
game-maker / suite (push) Successful in 11m44s

A game that stutters gave no hint where the frame goes. The Game tab
now has a Performance switch. It shows a small overlay in the top left
corner of the Game View while a game runs: fps, the number of entities
and the mean milliseconds per frame for each area, averaged over half
a second like the fps counter.

- src/editor/frameMeter.ts holds the pure rule. FrameMeter sums the
  areas per frame, closes a window every 0.5 s and formats the lines.
- World.timeSystem times every system the world ticks. PlaySession
  maps the systems to Behaviors, Physics and Animation and sets the
  hook again after Load scene.
- Animation has its own line. Counting the AnimationSystem under
  Behaviors would have skewed that number.
- Drawing is the build of the game picture plus app.render(). It is
  main thread time only. The GPU work after it is not in the number,
  and app.render() draws the whole canvas including the panels.
- Editor is the rest of the editor tick after the systems and the game
  picture: mirroring into the model, panels and console.
- The overlay lets clicks through to the game. It shows dashes until
  the first window closes. The switch is off by default and is not
  saved. The released game (#266) runs without a meter.

Tests:
- Unit frame-meter: 9 passed.
- Gate on melektaus-atx: 197 files, 2853 tests, CHECK EXIT 0.
- e2e 59 on melektaus-atx: ALL PASSED, 18 checks (13 before, +5 in
  59e with a real mouse on the switch). Run twice.
- Three mutations were caught: the editor share not subtracting the
  systems (2 unit tests), systems running in pause not reported
  (1 unit test), the overlay getting no times (59e).
- The e2e total of 1601 is computed (1596 + 5), not measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-30 09:44:53 +02:00
1 parent d471150efb
commit 77f4c2c1a3
13 files changed
+436 -5

No files matched your search

+16
View File
@@ -126,6 +126,22 @@ export function sceneHooks({ state, editor }: HookContext) {
headerButton: shownOnStage(gamePane.fullscreenButton) ? centreOf(gamePane.fullscreenButton) : null,
corner: shownOnStage(gameView.fullscreenButton) ? centreOf(gameView.fullscreenButton) : null,
}),
/**
* The performance overlay (#275): the header switch, whether the overlay is on screen, where,
* and the lines it shows. The numbers behind them are in `playInfo().performance`.
*/
gamePerformance: () => {
const overlay = gameView.performanceOverlay;
const origin = overlay.getGlobalPosition();
const button = gamePane.performanceButton;
return {
button: { ...centreOf(button), lit: button.toggled },
shown: shownOnStage(overlay),
box: { x: origin.x, y: origin.y, w: overlay.width, h: overlay.height },
view: rectOf(gameView),
lines: overlay.lines,
};
},
/** Which typeface a text ended up drawn in, and how wide it made it. */
textInfo: (id: string) => viewport.textInfo(id),
gameTextInfo: (id: string) => gameView.textInfo(id),