Thanks for all the responses, highly appreciated!
> This is not the biggest reason of the slowdown, but it's still surprising
> that wxComboBox takes up to 50% longer than wxChoice to create when it's
> the same underlying control. So the difference here must come from
> something we do in wx code and so it might be possible to optimize it.
The case I profiled had 15x wxChoices, but only two wxComboBoxen. I
know the system I'm using is pretty noisy, so I re-run profiles many
times to get an average overall runtime and use a reasonable profile
to work from, discarding all runs which took 1.5-3x longer than that
average. I've seen the differences across a few different runs though,
so I suspect it is real and not just noise.
All of these widgets get a fixed list of choices supplied through
wxArrayString. There are generally two to four choices, almost never
more than that.
Since 16 ms is a suspicious number near GUIs, I tried this with 24 Hz
refresh as well, but it takes just as long - so at least it's not
something locked to the refresh.
> Would you have more details from your profiling runs about this, in
> particular about the difference between these two controls? The problem is,
> of course, that CreateWindow() sends out messages and I'm not sure how can
> you account for the time taken handling them when profiling. The best would
> probably be to create a simple test program creating a hundred or two of
> wxChoices, profile it, save the results, then change it to create
> wxComboBoxes, profile the new version and compare the results. Are there
> any salient differences?
I will try to get more data on this.
> A hidden wxFrame should still have a HWND. Do you mean a not created
wxFrame perhaps?
Yes, I accidentally wrote it the wrong way. Tried it again with a
hidden wxFrame, however,
it makes no difference w.r.t. performance.
> If the problem is really with just wxChoice and wxComboBox, perhaps you
> could try using wxComboCtrl instead? It would be surprising if it were
> faster than the native control, but could be worth checking.
I can confirm that wxComboCtrl is indeed much faster than
wxChoice/wxComboBox to create, it seems to fall squarely in the
"cheap" category. I didn't provide a wxComboPopup though; looking at
the API it seems to be support lazy creation of the popup controls, so
it shouldn't have any impact in that area.
It is interesting to observe that the "cheap" widgets on MSW are still
super-slow compared to GTK. That group of widget takes like <0.2 ms to
create with GTK. I may not like many of GTK's design decisions, but it
sure looks to be far better optimized than Microsoft's GUI stack.
-----
> 1. We are newly creating pages of Win32 controls on demand, not at the application start up. Application starts very quickly, but page switching is slower.
We are essentially doing this already, our app supports multiple
worksheets at the same time, user selects desired type of worksheet,
which is then lazily created. However, inside the worksheet itself we
can't really lazily create anything, as it is all visible at the same
time.
> 2. To cope with slow page switching, we consolidated multiple labels with some other controls into our custom drawn control, thus reducing the number of controls significantly. Apart from the labels, the single control does layout of edit fields, shows and serves some indicator and undo buttons (we have three bitmap buttons rendered at each input line, all rendered and served by the same custom control). That was a very laborious process indeed, however it was the best we could do with wxWidgets wrapped Win32 controls. The speed up was extreme indeed.
I don't feel toooo amazed about that prospect, though killing off the
biggest offenders in our case with wxComboCtrl just for Windows might
be worth it, while retaining wxChoice (actually, we are using our own
custom-drawn faux-wxChoice on GTK, because GTK has rendering bug if
you reduce the height of a wxChoice) and wxComboBox for GTK, since
wxComboCtrl looks quite odd on GTK.
Cheers, Marian