[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] Speed *triples* by changing 'apply(f, args)' to 'f(*args)'
[This e-mail is sent to pygame-users and python-list]
Hi,
I was having troubles with a low framespeed. In my game,
1/3'rd of the time was in the warn() function:
84811 function calls (84805 primitive calls) in 11.340 CPU seconds
Ordered by: cumulative time
List reduced from 159 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.020 0.020 11.340 11.340 brian.py:169(main)
1 0.000 0.000 11.340 11.340 <string>:1(?)
1 0.000 0.000 11.340 11.340 profile:0(main())
1 0.060 0.060 10.150 10.150 brian.py:89(mainloop)
80 1.930 0.024 7.960 0.100 sprite.py:305(update)
24084 2.910 0.000 4.810 0.000 warnings.py:16(warn)
24084 1.890 0.000 1.900 0.000 warnings.py:51(warn_explicit)
This game ran at 3 fps with profile, 6 fps without. Note that it ran approk,
80 frames and warn was called 24000 times.
Then I changed in sprite.py:311, apply(f, args) to f(*args).
Framespeed tripled:
39894 function calls (39888 primitive calls) in 5.790 CPU seconds
Ordered by: cumulative time
List reduced from 151 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 5.790 5.790 brian.py:169(main)
1 0.000 0.000 5.790 5.790 <string>:1(?)
1 0.000 0.000 5.790 5.790 profile:0(main())
1 0.040 0.040 4.590 4.590 brian.py:89(mainloop)
88 0.860 0.010 2.200 0.025 sprite.py:311(update)
87 0.010 0.000 1.430 0.016 screen.py:64(drawbg)
87 1.420 0.016 1.420 0.016 util.py:264(tiled_blit)
1 0.000 0.000 1.160 1.160 level.py:113(__init__)
128 0.030 0.000 1.090 0.009 level.py:124(randsprite)
441 0.040 0.000 0.980 0.002 level.py:48(addsprite)
Now, it runs at approx. 9 fps with profile, and 18 without (still
unacceptable, but understandable).
Well. It seems warn() is being called but I don't receive warnings
to the console. I cannot explain this, but I noticed it.
This is Python 2.3a2.
yours,
Gerrit.
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
http://www.sp.nl/
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org