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

Re: [pygame] pygame.time.get_ticks() vs. time.clock()



On 5/24/07, Mike Wyatt <mikejohnwyatt@xxxxxxxxx> wrote:
I'm working on a synchronized RTS using pygame and Python's socket
library, and I've discovered that the values returned by
pygame.time.get_ticks() and the time module's clock() method are not
consistent.  My test results suggest that pygame.time.get_ticks() runs
slightly faster than time.clock().

time.clock() is not a good way to measure wall clock time portably. On
some systems (unix) it returns cpu time used instead of wall clock
time, and on windows it uses the cpu performance counters as source,
but does seem to return wall clock time. Use time.time() for getting
the time portably, or use get_ticks(). The important thing is that you
should use the same source everywhere.

Regards,
Ulf