makerplane / pyEfis

Electronic Flight Information System in Python
GNU General Public License v2.0
58 stars 31 forks source link

Optimize engine gauges #68

Open Maker42 opened 5 years ago

Maker42 commented 5 years ago

The currently checked in engine gauges repaint the entire gauge for every update/paint event in Python. This method has been shown to be very expensive based on profiler data.

If the more static parts of the gauge were in a graphicsview, and only the dynamic parts were repainted, there would likely be a large performance boost.

birkelbach commented 5 years ago

This is on the short list.

birkelbach commented 5 years ago

I've done some experiments with this and I have not been able to get much of a boost. The issue is that the text is expensive to draw in the QGraphicsScene. I got about a 15-20% boost without aligning the text. When I right aligned the text it was actually slower. This was because the position has to be calculated on each update. Without the alignment it wasn't too bad but I couldn't figure out how to right align text without calculating a new position each time the text changes. There might be a way.

There are probably some other optimizations we can do with the QWidget Gauges like making the static things a QPixMap or something instead of drawing them. I'm not sure, but I'll play with it some more.