Friday, June 15, 2012

Stress test

I have always love to optimize my code, to benchmark and make it run faster, many times I have found myself making life very complicated for no good reason, it is almost like an obsession to make my game run as fast as possible.

I got to the point where I wanted to try some stress testing on bear knight, I started with 1400 MS per tick by creating 700 slimes on the screen, making use of my profiler I found the culprits, the Quadtree, Behaviors and Action sorting.

Using lists as proven to me one of the slowest but sanest ways of dealing with large number of objects, but it was thanks to this that I had a huge bottle neck, constantly adding things to a list can be quite tasking.

I changed all my lists for Arrays like I had done before in other projects, as well as getting rid of the properties (even though every purist out there would be like "Oh no! Properties is the way to go you nasty coder!), in my opinion, if you wanted pretty code that is easy to read and safe, then you should stay away from Game Development. I love public and statics, global variables and the like of them, they make game development fast, and in a team sure it can cause problems, but it is the duty of the team to learn how the dynamics of the code are going, and at the end the game will run better, the same can be true for the opposite, but that depends.

Either way, Bear knight after my optimization is now running at 20-30 on average with 700 slimes on the screen:

beautiful video here: Slimes, Slimes, Slimes


No comments:

Post a Comment