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