[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Bullet Tests
Kris Schnee wrote:
I tried building a bullet recycling system, and I don't see a big
performance boost from it -- but it's hard to tell.
If you want to check it out, see:
http://kschnee.xepher.net/code/cestus_mk2.py
http://kschnee.xepher.net/code/cestus_mk2%20(no%20recycling).py
Those are versions of the shooter game hacked to run for 500 frames
with the player being invincible and the controls disabled, and the
random number generator "seeded" so that the same enemy pattern always
appears.
The weird thing is, in the first copy -- the one with recycling -- the
enemies mysteriously stop firing after a while. I put in a debug line
(currently commented out; search for "The guns -- they've stopped!")
to report on how many player, enemy, and spare bullets are in-game.
That line reports that bullets are getting recycled, all right, but
the enemies just stop shooting!
The ttl field of the recycled (technically re-used, since the bullet is
not made into something else) bullet is not reset. When that was fixed I
found no difference in FPS between recycling an no recycling. The
environmentalists won't be happy with this.
Anyway, the framerate difference I got was only something like 33 vs.
30 (recycling and not). It could be that my "graphics" and game logic
are too poor, so I tried running a test with the screen drawing
disabled, and got FPS of 38 vs. 37.
My Bullet class is really simple, though. You might get more of a
performance difference if you're using sentient 3D particle-trail
bullets with Wikipedia access.
Apparently the cost of memory management is nothing compared to the
overall life of the bullet.
Kris
(Bullet Bill: "*Sniff* I'm gonna miss ol' Buck -- he was a good shot!")
So I guess the reincarnation program will be discontinued.
--
Lenard Lindstrom
<len-l@xxxxxxxxx>