Premature optimization is the root of all evil
Note: frame times at the end.
The conversion of all modules from SharpDX to PyOpenGL is finished, so I ran the test program again. Result: 430 FPS (previously 649). Time to optimize.
First: check with cprofile module. Most time spent is in the shaders uniforms update, then in the events raising.
- After reducing some gpu calls, >> +20 FPS
- Converting many For loops to list comprehensions and map() >> +10FPS
I was worried because the achievements in frames where small, then I remembered the events reporting.
- After removing all the onRenderEnd calls, where I was doing rotation of the dragon and window title update >> +1000 FPS
The engine ended up running at 1500 FPS (max). Amazing, but unrealistic, since casting events is completely necessary. Maybe a threaded approach will give improvement in this point.
But since frame times is the right way to measure, I converted all numbers, getting:
- First gain: 0.1ms
- Second: 0.04ms
- Last: 1.5ms
Was it right? After trying the same program in my slow laptop, the timings probed to be correct… and meaningless. All of them:
The result in my laptop was of 58FPS, when before the improvements was of 50FPS. Only 2.7ms Total, after all the stuff I did and removed.
Final result: I’m done with optimizations. Maybe, optimizing before having something good is not good. I will move on to the next step, that will not be an editor this time.