Skip to content

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.

fix(perf): the budget gate can print a measurement that came out negative

esengine499a3f28dd5b
diff --git a/tools/perf-budget.mjs b/tools/perf-budget.mjs
index acf4648c4..9f6b8a864 100644
--- a/tools/perf-budget.mjs
+++ b/tools/perf-budget.mjs
@@ -139,6 +139,9 @@ function status(pct) { return pct > 100 ? 'FAIL' : pct > 70 ? 'near' : ' ok'; }
function meter(pct) {
const width = 20;
- const filled = Math.min(width, Math.round((pct / 100) * width));
+ // Clamped at BOTH ends: a measurement can legitimately come out negative (a
+ // heap that shrank), and an unclamped bar threw a RangeError instead of
+ // printing which measurement it was.
+ const filled = Math.max(0, Math.min(width, Math.round((pct / 100) * width)));
return `[${'#'.repeat(filled)}${'.'.repeat(width - filled)}]`;
}