[Twisted-Python] transport.write performance.
zipxing
zipxing at hotmail.com
Thu Aug 1 02:49:25 MDT 2013
pypy+builtin_json performance < cpython+ultrajson
________________________________
> Date: Wed, 31 Jul 2013 09:22:53 +0200
> From: _ at lvh.io
> To: twisted-python at twistedmatrix.com
> Subject: Re: [Twisted-Python] transport.write performance.
>
>
> On Jul 31, 2013 4:19 AM, "zipxing"
> <zipxing at hotmail.com<mailto:zipxing at hotmail.com>> wrote:
>>
>> Great! pypy take 20% cpu, 3x fast than cpython!
>> Thanks!
>>
>> A little problem: cjson and ujson can't install to pypy...
>
> What's wrong with the builtin json module?
>
>> ZipXing
>>
>> ________________________________
>>> From: _ at lvh.io<http://lvh.io>
>>> Date: Tue, 30 Jul 2013 13:09:33 +0200
>>> To:
> twisted-python at twistedmatrix.com<mailto:twisted-python at twistedmatrix.com>
>>> Subject: Re: [Twisted-Python] transport.write performance.
>>>
>>> Hi zipxing,
>>>
>>> You don't mention the interpreter. Is it CPython? What kind of results
>>> do you get trying it on PyPy?
>>>
>>> Also, you don't need to specify epollreactor. Recent versions of
>>> twisted will automagically choose the appropriate backend. I fixed this
>>> and some other cleanups and got:
>>>
>>> ----
>>> from time import clock
>>> from twisted.internet import protocol, reactor
>>> from twisted.protocols import basic
>>>
>>> class MeasuringEchoProtocol(basic.LineReceiver):
>>> MEASUREMENT_INTERVAL = 1000
>>>
>>> def lineReceived(self, data):
>>> self.factory.requests += 1
>>> if self.factory.requests % self.MEASUREMENT_INTERVAL == 0:
>>> print "RPS: {0}".format(self.factory.requests / clock())
>>>
>>> self.transport.write(data)
>>>
>>>
>>>
>>> class ServerFactory(protocol.ServerFactory):
>>> protocol = MeasuringEchoProtocol
>>>
>>> def __init__(self):
>>> self.requests = 0
>>>
>>>
>>>
>>> def main():
>>> reactor.listenTCP(9976, ServerFactory())
>>> clock()
>>> reactor.run()
>>>
>>> if __name__ == '__main__':
>>> main()
>>> ----
>>>
>>> Keep in mind that due to setup time few requests get handled right when
>>> it starts, so the server RPS will take some time to balance out. On my
>>> wimpy laptop on battery power, that was around 420.274404782.
>>>
>>> cheers
>>> lvh
>>>
>>> _______________________________________________ Twisted-Python mailing
>>> list
> Twisted-Python at twistedmatrix.com<mailto:Twisted-Python at twistedmatrix.com>
>>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com<mailto:Twisted-Python at twistedmatrix.com>
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
> _______________________________________________ Twisted-Python mailing
> list Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list