Conversation
…duce per-tick overhead Co-authored-by: daedeloth <1168599+daedeloth@users.noreply.github.com>
…rformance-low-end-devices
|
📦 PR Preview deployed! Examples are available at: |
|
@copilot i don't suppose there is a way to measure performance improvements? |
There's no built-in benchmark suite in this repo, but here are practical ways to measure the impact: Browser DevTools Performance panel – Record a session before/after in Chrome DevTools (Performance tab). Compare frame times and look for long-task markers in the flame chart, especially around Quick micro-benchmarks – Wrap the hot paths with var t0 = performance.now();
var text = this.goBigOrGoHome(this.textstring, space.width, space.height);
console.log('BigText fit: ' + (performance.now() - t0).toFixed(2) + 'ms');GC pressure (BigText) – The main BigText win is fewer allocations (~10 Placeholder lookup – The gains are most visible on low-end devices under real workloads (many BigText instances resizing, deep display trees) rather than in synthetic benchmarks. |
Frame rate drops and input lag on low-end devices traced to expensive per-frame operations in BigText, placeholder tree search, and redundant
getBounds()calls.BigText: reuse measurement object in binary search
goBigOrGoHomeBinarypreviously allocated a newcreatejs.Textper binary search step (~10 objects per resize). Now reuses a single measurement object, mutating onlyfont/lineHeight, and creates the final display object once at the end.MovieClipHelper: O(1) deep name lookup via pre-built map
buildNamedChildMapnow also builds_mh_deep_named_children_map— a flattened name→children[] index across all descendants.findFromNameInContaineruses this map for direct lookup instead of recursively walking_mh_named_children_mapon every call. The map is built once and cached alongside the existing_mh_named_children_map.Placeholder: guard z-index check in
_tickupdateZIndex()whenelement.parentis null, avoiding twogetChildIndexcalls per tick on orphaned elements.Eliminate duplicate
getBounds()callsBigText.getAvailableSpaceandBackground.getChildBounds/getAvailableSpacenow cache thegetBounds()result in a local variable instead of calling it 2-3× per invocation.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.