gitdefence / game-off-2012

Build networks, destroy bugs
http://www.justinmcgirr.com/gitdefence/master/game/
5 stars 1 forks source link

Performance #99

Open crazy2be opened 11 years ago

crazy2be commented 11 years ago

Our drawing code is really inefficient, and using what we've learned, we should be able to switch things over to the new drawing API with manual invalidation (already used by the GUI code).

Right now, in a game with a couple towers,

All of the other components, which used to have similar numbers, but have since switched over to the new drawing API, have numbers which are ~0-3%. Thus, optimizing the drawing of these components could easily yield a doubling of speed, on top of the previous doubling already gained by similar optimizations.

Interesting fact: The drawing code currently takes ~65% of the runtime of the program, 48% of which is the towers (two in this case), bugs (simple circles!), and infobar (hardly ever changes!). That means everything else, including the tower bar at the side, the buttons and labels for the GUI, the gameboard, and the game path, take a mere 17% when combined together, thanks to optimizations like this one.

crazy2be commented 11 years ago

Pretty impressive improvements, I can now almost get a smooth 30fps in chrome on my phone, up from like 10fps when we started. On my computer, I'm getting ~40fps, up from ~15fps when we started. With a few more of the optimizations mentioned above, we should be able to get at least a ~25% additional improvement (although probably more!).