[pyddr-devel] Performance, frame rate, and judging

Dean Brettle dean at brettle.com
Mon Jul 19 16:56:33 EDT 2004


On Sun, 2004-07-18 at 17:42, Stephen Thorne wrote:
<snip>
> Submit the patch anyway, thankyou. :)
> 
> Stephen.

Attached.  Note: This is the first Python code I've ever written, so
please forgive any clumsiness you see.

I added pad.queue_events() which polls the pygame and sticks the
resulting events on an internal queue along with a timestamp attribute. 
pad.queue_events() also keeps a list of long delays ( > 22.5 ms) between
calls.  More on that in a moment...

I moved most of the original functionality from pad.poll() into
pad.poll_with_time() but changed it to call pad.queue_events() and then
get events from the internal queue instead of polling pygame directly. 
pad.poll_with_time() returns a triple instead of a double like
pad.poll() did.  The additional third element is the timestamp.

For backward compatibility, I changed pad.poll() to call
pad.poll_with_time() and return just the first 2 elements of the result.

I sprinkled calls to pad.queue_events() around dance.py, and player.py,
and added a call pad.save_delays() at the end of dance.dance(). 
pad.save_delays() writes info about the aformentioned long delays to
delays.csv for analysis with your favorite tool.

With the patch I get about 30 FPS (down from 50 FPS without it).  Some
of the calls to pad.queue_events() could probably be removed but I
hadn't figured out which ones.  The swath_height used in dance.dance()
is probably the key to controlling the performance impact of the patch.

Hope that helps,

--Dean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: poll_with_time.patch
Type: text/x-patch
Size: 7335 bytes
Desc: not available
URL: <http://icculus.org/pipermail/pyddr-devel/attachments/20040719/e16cf093/attachment.bin>


More information about the pyddr-devel mailing list