Create a gist now

Instantly share code, notes, and snippets.

@pawl /test.py Secret
Last active Aug 11, 2017

What would you like to do?
testing verify=False vs verify=True with gevent
import urllib3
import timeit
import gevent
import requests
from gevent import monkey
monkey.patch_all()
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def test_request(verify):
resp = requests.get(
'https://www.instagram.com/instagram/?__a=1',
verify=verify,
)
resp.raise_for_status()
start_time = timeit.default_timer()
for x in range(100):
test_request(verify=True)
print "verify=True took:", timeit.default_timer() - start_time, "secs"
start_time = timeit.default_timer()
for x in range(100):
test_request(verify=False)
print "verify=False took:", timeit.default_timer() - start_time, "secs"
start_time = timeit.default_timer()
gevent.wait([gevent.spawn(test_request, True) for x in range(100)])
print "gevent verify=True took:", timeit.default_timer() - start_time, "secs"
start_time = timeit.default_timer()
gevent.wait([gevent.spawn(test_request, False) for x in range(100)])
print "gevent verify=False took:", timeit.default_timer() - start_time, "secs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment