Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Am I crazy or is it actually going this fast? (MultiThreading)

from tornado import httpclient
import time

start = time.time()

for x in range(1000):
    httpclient.AsyncHTTPClient().fetch("https://www.google.com", method="GET")

print ('{0} seconds'.format(time.time() - start))

Result 1.11500000954 seconds

I wrote this to see how fast I can send 1000 requests to any site (I chose google) and I don't know why, but I feel like I did something wrong and its not actually going this quick, if I did do something wrong, could someone point out my error?

Thank you!

like image 536
niro Avatar asked Nov 24 '25 19:11

niro


1 Answers

Well, yes, you spun off 1000 asynchronous requests to Google and timed that. You did not, however, time the overhead of actually making the HTTP call. That would require a callback-type of handler.

like image 62
stdunbar Avatar answered Nov 27 '25 08:11

stdunbar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!