This is just some hacking I did while profiling AE, looking for wasted cpu cycles. In the meantime I needed a way to test small changes and their impact on the CPU in some measurable way, this was the result. It's not particularly pretty, and only useful for internal testing, but it's better than nothing.
The 3 optims address the top 3 cpu consumers on their own. The result of some optimizing was a 5.8% decrease in average frame-time, excluding gpu operations as this was done with d-r+noflip on a static scene.
Just putting this out there for discussion, not for Frodo.
profile: Add a very dumb benchmark tool for profiling
At most, this lets us measure before/after frame-times when tweaking small but
busy parts of the codebase.
profile: MULTI_INFO is hit ~75% of the time, make it the first check
profile: Cache controls' render regions to avoid the costly generateAABB
profile: stack.size() can be O(n) and these are done hundreds of time…
…s per frame. Keep track of the size instead.
It's using stack.size() pointlessly in som cases. empty() or first()!
=end() is much faster and smaller change.
@elupus Yup, my first thought was to just use .empty() instead, but since we need to be able to return the size in 2 places (including RemoveTransform(), which gets the most traffic) I opted for local storage. I'm happy to do that though if there's an issue with caching it, other than it being ugly and non-obvious.
You can probably kill the returning of the stack size in RemoveTransform. It's used only for debugging stuff, which has long been fixed. Instead, adding a function wrapped in _DEBUG to check the stack size might be a better way to go.
I've forced a rebase by fixing up the .empty/size stuff above in master.
closing for now as it's semi merged already