Cantabile Development Blog

Follow the development of music software Cantabile

Articles | Full Index | RSS Feed


Performance tuning the UI

Today I've been performance tuning Cantabile's new UI. Normally I'd leave this to later in the project but I want to be sure that its going to be sufficiently fast before integrating it with Cantabile proper.

I'm always surprised with what I find when doing this sort of work. Usually I have a reasonable idea where the bottlenecks are but I nearly always I find something totally unexpected.

Before I started this it was taking about 180 milliseconds for the UI to completely render itself (at around 1000x700).

The first and most obvious thing I fixed was rendering of completely transparent items. The skinning library is setup so that all states of a UI element come from an image resource. For toolbar buttons the default background is completely transparent. Given that a large part of the UI is comprised of toolbar buttons this was a stupid waste of CPU. I now scan each element piece on its first render to see if it is completely transparent, and if so I know not to both rendering it in future. Fixing this nearly halved the render time down to about 100ms.

Next (and this is what surprised me), under Vista the title text is rendered with a "glow" effect around the title text. This is necessary as the title glass is translucent and could therefore be any color. To ensure the text is visible against the background Vista uses a white glow around the text. This looks nice but was taking about 60 ms to render! That's more than a quarter of the total original render time - just for the caption text. I now cache this in an off-screen bitmap and just copy to the screen.

Total render time is now down to about 40ms - one fifth of the original. Not bad for a few simple changes. Under XP it now feels reasonably responsive, but under Vista it's still a little sluggish. Most of the render time is now in rendering the slider and level meter backgrounds so tomorrow I'll probably be looking at caching some of these common elements in their stretched state.

Posted on July 25, 2007

Share This

Leave A Comment

All comments will be reviewed for spam before being displayed.