--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
import timeitimport timefrom tornado import genfrom tornado.ioloop import IOLoopfrom tornado.httpclient import AsyncHTTPClient
io = IOLoop.instance()
@gen.coroutinedef simple_speed(): client = AsyncHTTPClient() for i in range(5): yield client.fetch(url)
@gen.coroutinedef curl_speed(): AsyncHTTPClient.configure('tornado.curl_httpclient.CurlAsyncHTTPClient') client = AsyncHTTPClient() for i in range(5): yield client.fetch(url)
# WARNING: comment the three line, the next will finish quickstart = time.time()print 'simple', simple_speed()print 'end', time.time() - start
start = time.time()print 'simple', curl_speed()print 'end', time.time() - startand also, when I useio = IOLoop.instance()io.run_sync(simpe_speed, timeout=10000000)it will always give a timeout-error, even though I have set the timeout paramters to a very big number.but the curl_speed works ok.
import timeitimport tornado.simple_httpclientimport tornado.curl_httpclientfrom tornado import genfrom tornado.ioloop import IOLoop
io = IOLoop.instance()
@gen.coroutinedef simple_speed(): client = tornado.simple_httpclient.SimpleAsyncHTTPClient() for i in range(5): yield client.fetch(url)
@gen.coroutinedef curl_speed(): client = tornado.curl_httpclient.CurlAsyncHTTPClient() for i in range(5): yield client.fetch(url)
print "simple", timeit.repeat("io.run_sync(simple_speed, timeout=3600)", setup="from __main__ import simple_speed, io", number=3)print "curl", timeit.repeat("io.run_sync(curl_speed, timeout=3600)", setup="from __main__ import curl_speed, io", number=3)
simple [59.33778500556946, 62.93559217453003, 71.27185702323914]curl [11.058576107025146, 2.5515811443328857, 2.5450439453125]