glitchless-playtest 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # glitchless-playtest
2
2
 
3
- Playtest every change. Autoplay bots play your web game on a saved baseline and on the current code,
4
- and [Glitchless](https://github.com/glitchless-gg/glitchless) compares the two runs: slow frames,
5
- render time, draw calls, hitches, errors, deaths and level completion. A regression exits with code 1,
6
- so it can gate a pull request.
3
+ Playtest every change. Autoplay bots play your web game (Three.js, Phaser or plain WebGL) on a saved
4
+ baseline and on the current code, and [Glitchless](https://github.com/glitchless-gg/glitchless) compares
5
+ the two runs: slow frames, render and update time, draw calls, hitches, errors, deaths and level
6
+ completion. A regression exits with code 1, so it can gate a pull request.
7
7
 
8
8
  ```bash
9
9
  npx glitchless-playtest --save baseline # before changing the code
@@ -24,6 +24,11 @@ npx glitchless-playtest # after: compares with "baseline"
24
24
 
25
25
  A run ends after `max_s` seconds, or as soon as the page sets `window.__GLITCHLESS_PLAYTEST_DONE__ = true`.
26
26
 
27
+ On a fast machine, vsync hides a slower build in frame time. Render CPU and update CPU per frame don't
28
+ hide it, so they fail a run on their own: update CPU is the game's update code, which the SDK times
29
+ where the engine lets it (Phaser's scene updates and physics). The Phaser demo in the Glitchless repo,
30
+ `apps/phaser-demo`, has a working `glitchless.playtest.json`.
31
+
27
32
  ## Options
28
33
 
29
34
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "glitchless-playtest",
3
- "version": "0.1.1",
4
- "description": "Playtest bots for game observability: autoplay bots play your web game on the current code and on a saved baseline, and Glitchless flags what got slower or started breaking.",
3
+ "version": "0.2.0",
4
+ "description": "Playtest bots for game observability: autoplay bots play your web game (Three.js, Phaser) on the current code and on a saved baseline, and Glitchless flags what got slower or started breaking.",
5
5
  "keywords": [
6
6
  "playtesting",
7
7
  "playtest",
@@ -14,6 +14,7 @@
14
14
  "regression-testing",
15
15
  "playwright",
16
16
  "threejs",
17
+ "phaser",
17
18
  "web-games",
18
19
  "mcp"
19
20
  ],
package/src/compare.js CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  import { DEFAULT_THRESHOLDS } from './config.js';
5
5
 
6
- const OVERALL = ['pct_frames_over_budget', 'frame_p95', 'render_cpu_ms', 'draw_calls', 'hitches_per_min', 'errors_per_session', 'deaths_per_session', 'level_completion_pct', 'geometries_growth_per_level_load'];
7
- const PER_LEVEL = ['pct_frames_over_budget', 'frame_p95', 'render_cpu_ms', 'draw_calls'];
6
+ const OVERALL = ['pct_frames_over_budget', 'frame_p95', 'render_cpu_ms', 'update_cpu_ms', 'draw_calls', 'hitches_per_min', 'errors_per_session', 'deaths_per_session', 'level_completion_pct', 'geometries_growth_per_level_load'];
7
+ const PER_LEVEL = ['pct_frames_over_budget', 'frame_p95', 'render_cpu_ms', 'update_cpu_ms', 'draw_calls'];
8
8
 
9
9
  export function judge(before, after, t) {
10
10
  if (before == null || after == null || !t) return null;
package/src/config.js CHANGED
@@ -22,6 +22,8 @@ export const DEFAULT_THRESHOLDS = {
22
22
  pct_frames_over_budget: { label: 'Slow frames (% over budget)', higher: true, pct: 50, abs: 2, severity: 'fail' },
23
23
  frame_p95: { label: 'Frame time p95 (ms)', higher: true, pct: 15, abs: 2, severity: 'warn' },
24
24
  render_cpu_ms: { label: 'Render CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
25
+ // The game's update code (scripts and physics), where the SDK can time it: Phaser, Godot and Unity.
26
+ update_cpu_ms: { label: 'Update CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
25
27
  draw_calls: { label: 'Draw calls per frame', higher: true, pct: 25, abs: 50, severity: 'fail' },
26
28
  hitches_per_min: { label: 'Hitches per minute', higher: true, pct: 50, abs: 1, severity: 'warn' },
27
29
  errors_per_session: { label: 'Errors per run', higher: true, pct: 50, abs: 1, severity: 'warn' },
@@ -32,6 +34,7 @@ export const DEFAULT_THRESHOLDS = {
32
34
  'level.pct_frames_over_budget': { label: 'Slow frames (% over budget)', higher: true, pct: 50, abs: 2, severity: 'fail' },
33
35
  'level.frame_p95': { label: 'Frame time p95 (ms)', higher: true, pct: 15, abs: 2, severity: 'warn' },
34
36
  'level.render_cpu_ms': { label: 'Render CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
37
+ 'level.update_cpu_ms': { label: 'Update CPU per frame (ms)', higher: true, pct: 30, abs: 1, severity: 'fail' },
35
38
  'level.draw_calls': { label: 'Draw calls per frame', higher: true, pct: 25, abs: 50, severity: 'fail' },
36
39
  new_errors: { label: 'New error types', severity: 'fail' },
37
40
  new_crashes: { label: 'Crashed runs', severity: 'fail' },
package/src/report.js CHANGED
@@ -49,6 +49,7 @@ export function runReport(run) {
49
49
  ['Slow frames (% over budget)', s.pct_frames_over_budget],
50
50
  ['Frame time p95 (ms)', s.frame_p95],
51
51
  ['Render CPU per frame (ms)', s.render_cpu_ms],
52
+ ...(s.update_cpu_ms != null ? [['Update CPU per frame (ms)', s.update_cpu_ms]] : []),
52
53
  ['Draw calls per frame', s.draw_calls],
53
54
  ['Hitches per minute', s.hitches_per_min],
54
55
  ['Errors per run', s.errors_per_session],
@@ -59,8 +60,9 @@ export function runReport(run) {
59
60
  for (const [k, v] of rows) out.push(`| ${k} | ${fmt(v)} |`);
60
61
  const levels = Object.entries(s.levels || {});
61
62
  if (levels.length) {
62
- out.push('', '| Level | Slow frames (%) | Frame p95 (ms) | Draw calls | Render CPU (ms) |', '| --- | ---: | ---: | ---: | ---: |');
63
- for (const [l, v] of levels) out.push(`| ${l} | ${fmt(v.pct_frames_over_budget)} | ${fmt(v.frame_p95)} | ${fmt(v.draw_calls)} | ${fmt(v.render_cpu_ms)} |`);
63
+ const update = levels.some(([, v]) => v.update_cpu_ms != null);
64
+ out.push('', `| Level | Slow frames (%) | Frame p95 (ms) | Draw calls | Render CPU (ms) |${update ? ' Update CPU (ms) |' : ''}`, `| --- | ---: | ---: | ---: | ---: |${update ? ' ---: |' : ''}`);
65
+ for (const [l, v] of levels) out.push(`| ${l} | ${fmt(v.pct_frames_over_budget)} | ${fmt(v.frame_p95)} | ${fmt(v.draw_calls)} | ${fmt(v.render_cpu_ms)} |${update ? ` ${fmt(v.update_cpu_ms)} |` : ''}`);
64
66
  }
65
67
  if (s.errors?.length) {
66
68
  out.push('', 'Errors:');