[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] strange behavior with pygame.time module



On Thu, Jun 08, 2006 at 03:21:17PM +0300, Sami Hangaslammi wrote:
> I'm not an expert on these issues, but the way I understand it, sleep
> is so inaccurate, that for very small delays, you need a use a busy
> loop that polls the timer (causing 100% CPU utilization), whereas for
> longer delays sleep works ok.

I did a little test and at least on my machine, time.sleep(0.01) was
about as good as pygame.time.wait(10).  Neither were ever more than 10%
off, though sleep was always under, and wait was both under and over.

But I also did some reading on framerates and decided to shoot for 40fps
instead of 100.  That at least brought my cpu usage down to 40-some
percent using wait.  Perhaps I should stick with pygame's time stuff
in the interest of cross-platform consistency.  (haven't tested on any
other machines yet)

-- 
Nick Welch | mack @ incise.org | http://incise.org