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

Re: [pygame] 2D vector class



Matthias Baas wrote:

Ethan Glasser-Camp wrote:

By the way, just out of curiosity I tested the vector class (http://cgkit.sourceforge.net/doc2/vec3.html) in my cgkit package (http://cgkit.sourceforge.net):

I'll add another datapoint here, using the module I just announced (euclid). This is with the "_tuple" fix above, no psyco (doesn't exist on AMD64) and cgkit light (C++ one doesn't compile here).

<function ScreenTranslationTestVec2d at 0x2aaaab908aa0> runs at 58823.5 loops/s
that's 980.39 loops to fill 60 fps
or 49.02 at a 5.0% budget at 60 fps
<function ScreenTranslationTestVec2dTuple at 0x2aaaab908b18> runs at 66666.7 loops/s
that's 1111.11 loops to fill 60 fps
or 55.56 at a 5.0% budget at 60 fps
<function ScreenTranslationTestExplicit at 0x2aaaab908b90> runs at 1000000.0 loops/s
that's 16666.67 loops to fill 60 fps
or 833.33 at a 5.0% budget at 60 fps
<function ScreenTranslationTestCgkit at 0x2aaaab908c08> runs at 71428.6 loops/s
that's 1190.48 loops to fill 60 fps
or 59.52 at a 5.0% budget at 60 fps
<function ScreenTranslationTestEuclid at 0x2aaaab908c80> runs at 125000.0 loops/s
that's 2083.33 loops to fill 60 fps
or 104.17 at a 5.0% budget at 60 fps


My module, using __slots__, seems to benchmark around twice as fast as the others, excepting the straight assignment test. Results are even happier with Python 2.5 beta 3:

<function ScreenTranslationTestVec2d at 0x2aaaab749578> runs at 71428.6 loops/s
that's 1190.48 loops to fill 60 fps
or 59.52 at a 5.0% budget at 60 fps
<function ScreenTranslationTestVec2dTuple at 0x2aaaab7495f0> runs at 83333.3 loops/s
that's 1388.89 loops to fill 60 fps
or 69.44 at a 5.0% budget at 60 fps
<function ScreenTranslationTestExplicit at 0x2aaaab749668> runs at 1000000.0 loops/s
that's 16666.67 loops to fill 60 fps
or 833.33 at a 5.0% budget at 60 fps
<function ScreenTranslationTestCgkit at 0x2aaaab7496e0> runs at 76923.1 loops/s
that's 1282.05 loops to fill 60 fps
or 64.10 at a 5.0% budget at 60 fps
<function ScreenTranslationTestEuclid at 0x2aaaab749758> runs at 166666.7 loops/s
that's 2777.78 loops to fill 60 fps
or 138.89 at a 5.0% budget at 60 fps


That's a significant boost to everyone, signalling that we should all download and install Python 2.5 as soon as it's released :-)

Thanks Brian for writing the very useful benchmark script, I'll be keeping an eye on it during development. I expect you'll get the same performance I am if you use __slots__, a minor change.

Alex.