I've been working on optimizing Global Build Command, which is steadily getting polished enough to where I feel like I can release it into the wild. I managed to get the main logic loop to run an order of magnitude or two faster wrt huge numbers of jobs, and now the GL code is showing up as consistently most expensive. My benchmark for this has been to do an area reclaim over the whole of Quicksilver, which draws command icons (and also has to do worker-cost calculations) for every tree on the map, of which there are 9001 or so. I would have expected the logic (ie GameFrame) to have been most expensive, but it shows that DrawWorld() is, even after I moved visibility checks into Update(). I'm seeing ~30% CPU usage from my widget under the aformentioned benchmark conditions, zoomed all the way out, and not much better when zoomed in all the way.
I'm not really sure how the whole gl.PushMatrix/gl.PopMatrix thing works, except in my tinkering I found that many things will not draw properly unless those are called for every item being drawn. I tried unswitching the drawing loops, switching to indexed array-tables instead of hash tables, and lifting some invariant code (mainly calls to gl.Color) but that doesn't seem to have improved anything by much. I'm not sure that it's actually possible to make this code any faster, but if it were I wouldn't really know what to even look for.
Here's the isolated drawing code:
http://pastebin.com/SZkt3Stc
Knowledge is muchly appreciated.
