[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pygame] sForzando speed update



On Fri, 2 Nov 2001, Michael Robin wrote:

> >I really have no idea what's up at this point.  It seems like redrawing the
> >whole screen every frame is actually FASTER than redrawing small bits of it
> >that change.  I don't have a clue why.

I'd recommend everyone to use the profile and pstats module. It's really
easy and you don't need to go to another computer to check if new ideas
are faster. But more importantly, instead of guessing, it gives you hard
info about which solutions are better, or why the bad ones are
inefficient.

The whole idea goes like this:

Say your code starts with the run of a function called 'main'. To profile
your code, you modify your program like this:

import profile

# your code here
.
.
.

profile.run ('main ()', 'foo_file')

Run your code and make it do stuff.

Later, maybe in another terminal, just run python, to get the interpreter.

Then put the following commands:

> import pstats
> p = pstats.Stats ('foo_file')
> p.print_stats ()

You get all kinds of statistics about the running time of your code, by
function.

This way you can repeat these two easy steps with different code and
compare efficiency in a more accurate way. Try running the different
versions of the code twice to make the program and resources to be loaded
in the OS cache, to get more-or-less equal times.

More info on this here:

http://www.python.org/doc/current/lib/profile.html

Greetings,
Arturo


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org