sudara / melatonin_inspector

A JUCE module that gives you the ability to inspect and visually edit (non-destructively) components in your UI.
MIT License
145 stars 17 forks source link

Preliminary Perfetto findings #76

Closed sudara closed 1 year ago

sudara commented 1 year ago

Note: All these timings are Debug (important context for the inspector) and just performed on my main app, which does have a lot of components ~but not outrageous~.

Outline Component

8735 calls to close subitems, adding up to 137ms.

Google Chrome - 2023-08-25 24@2x

Select Component

Again, recursively closing is an offender, and it's called twice.

Google Chrome - 2023-08-25 31@2x

Toggle

Looks likeComponentModel::selectComponent is called twice

Google Chrome - 2023-08-25 30@2x

,

sudara commented 1 year ago

Looks like the preview snapshot is also being called twice per ComponentModel::updateModel

Google Chrome - 2023-08-25 30 2@2x

sudara commented 1 year ago

Color picker is doing a good job being efficient

Google Chrome - 2023-08-25 31 2@2x

sudara commented 1 year ago

restoreBoundsIfNeeded sorta takes up a gross 15ms when the inspector closes.

Google Chrome - 2023-08-25 41@2x

sudara commented 1 year ago

The preview snapshot and doubling up on selection/tree closing is fixed in #80.

restoreBoundsIfNeeded is a tricky one. As expected, resized being called multiple times is hurtful.

Google Chrome - 2023-08-29 42@2x

sudara commented 1 year ago

Post optimization Debug times:

initial tree construction of > 8k items and inspector construction in 37ms: Google Chrome - 2023-08-30 01@2x

select component in 1.6ms:

Google Chrome - 2023-08-30 35@2x

Outline component in 3ms Arc - 2023-08-30 55@2x

toggle back on in 25ms: Arc - 2023-08-30 57@2x

toggle off in 21ms: Google Chrome - 2023-08-30 33@2x

lowest hanging fruit left is probably restoring bounds

sudara commented 1 year ago

Almost all time is spent in setResizable — it seems to call recreateDesktopWindow.

Google Chrome - 2023-08-30 16@2x

sudara commented 1 year ago

Without calling setResizable, toggle off is down to 1.5ms

Google Chrome - 2023-08-30 55@2x

And toggle on is down to 1.2ms Google Chrome - 2023-08-30 33 2@2x

There's not much change in behavior since setResizeLimits is still being called, so that prevents unintentional UI states (like resizing the inspector when disabled).