Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
23 stars 7 forks source link

fix: reduce dashboard CPU usage via fewer draws #94

Closed dan-da closed 6 months ago

dan-da commented 6 months ago

The dashboard was constantly using around 15% CPU on my system while doing basically nothing. This drops usage to under 1% for all screens.

The high usage was caused by constantly re-drawing the screen in the main loop.

The implemented fix is to add a RefreshScreen event which is sent by sub-screens when data or key events occur that require a redraw.

In this way, redraws only occur when required.


I am not certain this is the best or most elegant way to fix it, but it seems to works well on my system.

Testing: I tested functionality in all screens and compared with a dashboard instance running the previous code, and they appear to function identically, including the send screen which has some tricky stuff grabbing user input and moving control focus.

dan-da commented 6 months ago

@Sword-Smith pls review if u wish, or else I can just merge it.