A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(probe): a truncated system list is a lower bound on its own total
esengine1ebe4283edf4
diff --git a/pipeline/src/runtime/gameHost.ts b/pipeline/src/runtime/gameHost.tsindex 555f055bc..8ad2c7713 100644--- a/pipeline/src/runtime/gameHost.ts+++ b/pipeline/src/runtime/gameHost.ts@@ -485,18 +485,20 @@ async function boot(): Promise<void> {* shows on no system timer, while registering what it spawned happens* inside systems on the frames after. Engaging the stats fills this.*/- costs(top = 8): { on: boolean; systems: Array<{ name: string; ms: number }> } {+ costs(): { on: boolean; systems: Array<{ name: string; ms: number; domain: string }> } {// Engaged once. Re-enabling every call swaps the maps the frame just// filled, which reads as an engine that costs nothing.if (!statsOn) { app.enableStats(); statsOn = true; }const costs = app.getFrameCosts();if (!costs) return { on: false, systems: [] };+ // EVERY system, not the dearest few: what a caller wants to know about+ // an arrival frame is how much of it the breakdown explains, and a+ // truncated list can only ever be a lower bound on its own total.return {on: true,systems: [...costs.systems]- .map((s) => ({ name: s.name, ms: s.ms }))- .sort((a, b) => b.ms - a.ms)- .slice(0, top),+ .map((s) => ({ name: s.name, ms: s.ms, domain: s.domain }))+ .sort((a, b) => b.ms - a.ms),};},/** Drive a hot update against a served (CDN) manifest: fetch + diff + apply.diff --git a/tools/launchers/residency-run.mjs b/tools/launchers/residency-run.mjsindex a21c55f6d..3c1ad56d5 100644--- a/tools/launchers/residency-run.mjs+++ b/tools/launchers/residency-run.mjs@@ -253,7 +253,7 @@ async function main() {// Stats need a frame to fill, so they are engaged before the first// sample rather than by the first expensive one — which is the frame// whose breakdown matters most.- window.__estellaCooked.costs(1);+ window.__estellaCooked.costs();await window.__estellaCooked.step(1, 1 / 60);${step.key ? `send('keydown', ${JSON.stringify(step.key)});` : ''}const out = [];@@ -265,9 +265,17 @@ async function main() {const s = window.__estellaCooked.streaming();const row = { ms, resident: s.residentCells.length, loading: s.loadingCells.length,entities: s.entities, bodies: s.physicsBodies, physicsUp: s.physicsUp };- // Only where it can matter: a system breakdown of every frame is more- // data than a profile of one arrival needs.- if (ms > ${step.costsAbove ?? 1.5}) row.costs = window.__estellaCooked.costs(6);+ // Rolled up here, per frame: a steady state needs the cheap frames+ // broken down too, and sending every system of every frame overruns+ // the pipe to the bench (which reads as "nothing was measured").+ const costs = window.__estellaCooked.costs();+ row.on = costs.on;+ row.domains = {};+ for (const c of costs.systems) row.domains[c.domain] = (row.domains[c.domain] ?? 0) + c.ms;+ for (const d of Object.keys(row.domains)) row.domains[d] = Math.round(row.domains[d] * 1000) / 1000;+ // The per-SYSTEM detail only where it can matter: which system inside a+ // domain is a question worth asking of an expensive frame alone.+ if (ms > ${step.costsAbove ?? 1.5}) row.costs = costs.systems.filter((c) => c.ms > 0.01);out.push(row);// A macrotask turn between frames. Awaiting a step only drains// MICROtasks, and a cell arrives over the network — so a loop without