[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] sForzando speed update
On Sat, 3 Nov 2001 02:33:19 -0500 (EST)
Arturo Espinosa Aldama <arturo@ximian.com> wrote:
> 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
>
>
One problem with this though is that the actual time you spend blitting is not
accumulated in the cumulative time of a function call. (At least this was how
it worked the last time I tried it.) Something to do with profile not profiling
other threads, I think.
--
name: David Creswick
website: http://braznet.com/david
jabber id: davec@jabber.org
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org