[Twisted-Python] Twisted and python-ogre
exarkun at divmod.com
Fri Feb 15 10:51:27 EST 2008
On Fri, 15 Feb 2008 10:31:14 -0500, Bernie Roehl <broehl at gmail.com> wrote:
>On Thu, Feb 14, 2008 at 1:30 PM, Bernie Roehl <broehl at gmail.com> wrote:
>> I'm also wondering what would be the advantages of using a coiterator...?
>As an experiment, I tried switching to using a coiterator. I got a 30%
>increase in framerate!
>My code now looks like this:
>class RendererIterator: # used if usingCoiterator is True
> def __iter__(self):
> return self
> def next(self):
>from twisted.internet.task import coiterate
>Seems to work okay, but haven't tested it extensively.
>Any Twisted-gurus have any comments/suggestions/cautions?
There shouldn't really be any performance difference between using
coiterate and using LoopingCall. The significant behavioral difference
is that coiterate will call your code (RendererIterator.next in this
case) as fast as it can (with some constraints). LoopingCall will call
your code no faster than you specify.
So my guess is that the 30% increase in FPS is because your system is
capable of doing that much additional work above what you asked to do
when you used LoopingCall. If you make a corresponding decrease in the
interval you use with LoopingCall, do you not see any increase in FPS?
If not, then you may be getting a bit of extra performance from coiterate
from its behavior of sometimes calling your code multiple times without
letting the reactor run. It will do this if it notices your code runs
very quickly and so decides that it can afford to call it again before
giving control back to the reactor to let network events be processed.
This may give you a somewhat unevent frame rate, as compared to LoopingCall,
but that might be suitable for your application.
More information about the Twisted-Python