Skip to content

Instantly share code, notes, and snippets.

@methane
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save methane/70e0a5595f1076bbf726 to your computer and use it in GitHub Desktop.
Save methane/70e0a5595f1076bbf726 to your computer and use it in GitHub Desktop.
import cProfile
import requests
import time
import pycohttpp.monkeypatch
def run_with_profile():
prof = cProfile.Profile()
prof.enable()
run()
prof.disable()
prof.print_stats('time')
def run():
t0 = time.time()
for _ in range(1000):
resp = requests.get('http://127.0.0.1:8080/', stream=False)
assert resp.content == b'Hello, World!\n'
resp.close()
t1 = time.time()
print(t1-t0)
run()
pycohttpp.monkeypatch.patch_http_client()
run()
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
keepalive_timeout 120;
keepalive_requests 1000;
#access_log logs/access.log main;
access_log off;
server {
listen 8080;
server_name localhost;
location / {
echo "Hello, World!";
}
}
}
2.0779428482055664
1984295 function calls (1981295 primitive calls) in 2.073 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1000 0.146 0.000 0.146 0.000 {built-in method _get_proxy_settings}
1000 0.112 0.000 0.112 0.000 {built-in method _get_proxies}
92000 0.076 0.000 0.321 0.000 _collections_abc.py:496(__iter__)
78000 0.071 0.000 0.187 0.000 os.py:628(__getitem__)
191002 0.052 0.000 0.106 0.000 {built-in method isinstance}
1000 0.050 0.000 0.050 0.000 {method 'recv_into' of '_socket.socket' objects}
2000 0.048 0.000 0.344 0.000 request.py:2321(getproxies_environment)
78000 0.044 0.000 0.075 0.000 os.py:704(encode)
11005 0.044 0.000 0.110 0.000 _collections_abc.py:575(update)
147000 0.040 0.000 0.040 0.000 {method 'decode' of 'bytes' objects}
144000 0.040 0.000 0.079 0.000 os.py:708(decode)
27001 0.034 0.000 0.054 0.000 abc.py:178(__instancecheck__)
104002/103002 0.031 0.000 0.037 0.000 {method 'encode' of 'str' objects}
72000 0.030 0.000 0.068 0.000 os.py:651(__iter__)
7000 0.029 0.000 0.174 0.000 sessions.py:42(merge_setting)
8000 0.024 0.000 0.072 0.000 parse.py:286(urlparse)
178004 0.024 0.000 0.024 0.000 {method 'lower' of 'str' objects}
21000 0.022 0.000 0.026 0.000 parse.py:98(_coerce_args)
34000 0.021 0.000 0.021 0.000 {built-in method hasattr}
38001 0.021 0.000 0.021 0.000 _weakrefset.py:70(__contains__)
1000 0.018 0.000 0.831 0.001 sessions.py:538(send)
1000 0.018 0.000 0.300 0.000 connectionpool.py:317(_make_request)
7000 0.017 0.000 0.048 0.000 utils.py:147(to_key_val_list)
1000 0.017 0.000 0.017 0.000 {method 'sendall' of '_socket.socket' objects}
9000 0.017 0.000 0.030 0.000 parse.py:319(urlsplit)
10000 0.017 0.000 0.072 0.000 {method 'readline' of '_io.BufferedReader' objects}
2004 0.017 0.000 0.032 0.000 __init__.py:41(__init__)
1000 0.017 0.000 0.087 0.000 request.py:2360(_proxy_bypass_macosx_sysconf)
5000 0.016 0.000 0.024 0.000 client.py:1051(putheader)
1000 0.015 0.000 0.429 0.000 connectionpool.py:421(urlopen)
1000 0.014 0.000 0.022 0.000 socket.py:196(makefile)
1 0.014 0.014 2.078 2.078 bench.py:15(run)
2000 0.013 0.000 0.031 0.000 url.py:119(parse_url)
1000 0.013 0.000 2.057 0.002 sessions.py:385(request)
1000 0.013 0.000 0.646 0.001 adapters.py:323(send)
1000 0.013 0.000 0.407 0.000 sessions.py:345(prepare_request)
2000 0.012 0.000 0.012 0.000 {built-in method stat}
8000 0.012 0.000 0.042 0.000 _collections_abc.py:419(get)
5001 0.012 0.000 0.088 0.000 structures.py:42(__init__)
2000 0.011 0.000 0.032 0.000 posixpath.py:221(expanduser)
1000 0.011 0.000 0.135 0.000 client.py:344(begin)
1000 0.011 0.000 0.095 0.000 client.py:1107(_send_request)
2000 0.011 0.000 0.085 0.000 response.py:160(read)
2000 0.011 0.000 0.028 0.000 cookiejar.py:1638(extract_cookies)
2000 0.010 0.000 0.012 0.000 request.py:2376(ip2num)
5000 0.010 0.000 0.023 0.000 message.py:463(get)
1000 0.010 0.000 0.017 0.000 {built-in method gethostbyname}
1000 0.010 0.000 0.024 0.000 monkeypatch.py:10(parse_headers)
1000 0.010 0.000 0.040 0.000 client.py:605(_readinto_chunked)
1000 0.010 0.000 0.022 0.000 client.py:928(putrequest)
1000 0.010 0.000 0.062 0.000 utils.py:70(get_netrc_auth)
1000 0.009 0.000 0.071 0.000 models.py:334(prepare_url)
1000 0.009 0.000 0.035 0.000 models.py:539(__init__)
1000 0.009 0.000 0.074 0.000 client.py:312(_read_status)
17004 0.009 0.000 0.011 0.000 structures.py:48(__setitem__)
1000 0.009 0.000 0.798 0.001 sessions.py:617(merge_environment_settings)
1000 0.009 0.000 0.113 0.000 adapters.py:196(build_response)
14000 0.009 0.000 0.011 0.000 structures.py:53(__getitem__)
2002 0.008 0.000 0.012 0.000 idna.py:147(encode)
7000 0.008 0.000 0.010 0.000 _collections.py:154(__getitem__)
3001 0.008 0.000 0.017 0.000 cookiejar.py:1220(__init__)
22004 0.008 0.000 0.009 0.000 {method 'get' of 'dict' objects}
1000 0.008 0.000 0.051 0.000 response.py:278(from_httplib)
999 0.008 0.000 0.008 0.000 {method 'poll' of 'select.poll' objects}
1000 0.007 0.000 0.020 0.000 cookiejar.py:1315(add_cookie_header)
47036/46036 0.007 0.000 0.007 0.000 {built-in method len}
9000 0.007 0.000 0.013 0.000 _policybase.py:269(_sanitize_header)
4000 0.007 0.000 0.009 0.000 message.py:498(get_all)
2000 0.007 0.000 0.017 0.000 _collections.py:49(__getitem__)
8000 0.007 0.000 0.010 0.000 _collections_abc.py:438(items)
4000 0.007 0.000 0.007 0.000 {method 'match' of '_sre.SRE_Pattern' objects}
5001 0.006 0.000 0.011 0.000 cookiejar.py:1181(vals_sorted_by_key)
2000 0.006 0.000 0.006 0.000 {built-in method utcnow}
2001 0.006 0.000 0.030 0.000 cookies.py:424(cookiejar_from_dict)
8000 0.006 0.000 0.006 0.000 {method 'split' of 'str' objects}
4000 0.006 0.000 0.022 0.000 _collections_abc.py:426(__contains__)
2000 0.006 0.000 0.059 0.000 cookies.py:114(extract_cookies_to_jar)
3001 0.006 0.000 0.008 0.000 timeout.py:94(__init__)
1000 0.006 0.000 0.028 0.000 client.py:282(__init__)
2000 0.006 0.000 0.008 0.000 url.py:86(split_first)
3000 0.006 0.000 0.036 0.000 cookies.py:33(__init__)
1000 0.006 0.000 0.066 0.000 adapters.py:232(get_connection)
3001 0.006 0.000 0.006 0.000 cookiejar.py:854(__init__)
2010 0.006 0.000 0.008 0.000 threading.py:329(notify)
1000 0.006 0.000 0.179 0.000 models.py:298(prepare)
1000 0.006 0.000 0.018 0.000 _collections.py:230(extend)
1010 0.005 0.000 0.013 0.000 queue.py:118(put)
2000 0.005 0.000 0.009 0.000 parse.py:386(urlunsplit)
1000 0.005 0.000 0.168 0.000 client.py:1128(getresponse)
1000 0.005 0.000 0.005 0.000 socket.py:348(__init__)
1000 0.005 0.000 0.008 0.000 functools.py:356(_make_key)
20000 0.005 0.000 0.005 0.000 structures.py:60(<genexpr>)
1000 0.005 0.000 0.015 0.000 functools.py:455(wrapper)
2000 0.005 0.000 0.008 0.000 client.py:550(_read_next_chunk_size)
1000 0.005 0.000 0.006 0.000 models.py:210(__init__)
2000 0.005 0.000 0.008 0.000 __init__.py:176(pop)
1000 0.005 0.000 2.062 0.002 sessions.py:468(get)
1000 0.005 0.000 0.013 0.000 queue.py:150(get)
2000 0.005 0.000 0.104 0.000 models.py:719(content)
1000 0.005 0.000 0.006 0.000 response.py:91(__init__)
1000 0.005 0.000 0.005 0.000 {built-in method parse_headers}
2000 0.004 0.000 0.014 0.000 cookiejar.py:1558(make_cookies)
9000 0.004 0.000 0.004 0.000 {method 'startswith' of 'str' objects}
10000 0.004 0.000 0.004 0.000 {method 'find' of 'str' objects}
1000 0.004 0.000 0.005 0.000 socket.py:439(close)
5000 0.004 0.000 0.005 0.000 _collections.py:207(add)
9000 0.004 0.000 0.017 0.000 _policybase.py:299(header_fetch_parse)
2000 0.004 0.000 0.018 0.000 parse.py:375(urlunparse)
7000 0.004 0.000 0.016 0.000 sessions.py:70(<genexpr>)
1000 0.004 0.000 0.017 0.000 utils.py:663(get_auth_from_url)
4000 0.004 0.000 0.005 0.000 structures.py:59(__iter__)
10000 0.004 0.000 0.004 0.000 {built-in method __new__ of type object at 0x10e356a20}
5001 0.004 0.000 0.015 0.000 cookiejar.py:1185(deepvalues)
2000 0.004 0.000 0.092 0.000 response.py:256(stream)
1000 0.004 0.000 0.011 0.000 sessions.py:641(get_adapter)
1000 0.004 0.000 0.009 0.000 {method 'close' of '_io.BufferedReader' objects}
1000 0.004 0.000 0.009 0.000 models.py:414(prepare_body)
1000 0.004 0.000 0.030 0.000 connectionpool.py:210(_get_conn)
8000/7000 0.004 0.000 0.099 0.000 {method 'join' of 'bytes' objects}
5001 0.004 0.000 0.004 0.000 {built-in method sorted}
2000 0.004 0.000 0.004 0.000 socket.py:401(readable)
1000 0.004 0.000 0.012 0.000 message.py:460(<listcomp>)
2000 0.004 0.000 0.005 0.000 cgi.py:301(_parseparam)
8000 0.004 0.000 0.004 0.000 _collections_abc.py:456(__init__)
2000 0.004 0.000 0.013 0.000 cookies.py:444(merge_cookies)
2000 0.004 0.000 0.004 0.000 re.py:277(_compile)
2000 0.003 0.000 0.016 0.000 genericpath.py:16(exists)
2000 0.003 0.000 0.006 0.000 url.py:16(__new__)
9000 0.003 0.000 0.005 0.000 utils.py:51(_has_surrogates)
2000 0.003 0.000 0.008 0.000 timeout.py:154(clone)
3000 0.003 0.000 0.003 0.000 response.py:1(is_fp_closed)
1000 0.003 0.000 0.025 0.000 client.py:904(_send_output)
24005 0.003 0.000 0.003 0.000 {method 'items' of 'dict' objects}
1000 0.003 0.000 0.022 0.000 _collections.py:141(__init__)
5005 0.003 0.000 0.003 0.000 __init__.py:87(__iter__)
21000 0.003 0.000 0.003 0.000 parse.py:87(_noop)
1000 0.003 0.000 0.019 0.000 fnmatch.py:64(fnmatchcase)
999 0.003 0.000 0.013 0.000 connection.py:12(is_connection_dropped)
1000 0.003 0.000 0.013 0.000 models.py:74(_encode_params)
1000 0.003 0.000 0.055 0.000 socket.py:360(readinto)
1000 0.003 0.000 0.004 0.000 client.py:669(_safe_readinto)
1000 0.003 0.000 0.036 0.000 cookies.py:131(get_cookie_header)
3004 0.003 0.000 0.003 0.000 threading.py:75(RLock)
5000 0.003 0.000 0.005 0.000 models.py:410(<genexpr>)
1000 0.003 0.000 0.033 0.000 poolmanager.py:129(connection_from_url)
1000 0.003 0.000 0.012 0.000 utils.py:308(get_encoding_from_headers)
1000 0.003 0.000 0.007 0.000 cookiejar.py:1694(clear_expired_cookies)
1000 0.003 0.000 0.005 0.000 client.py:646(_safe_read)
2000 0.003 0.000 0.095 0.000 models.py:652(generate)
1002 0.003 0.000 0.003 0.000 __init__.py:62(__setitem__)
1000 0.003 0.000 0.436 0.000 utils.py:487(should_bypass_proxies)
1000 0.003 0.000 0.005 0.000 parse.py:713(quote_from_bytes)
6000 0.003 0.000 0.004 0.000 client.py:897(_output)
1001 0.003 0.000 0.003 0.000 __init__.py:1495(getEffectiveLevel)
1000 0.003 0.000 0.016 0.000 adapters.py:263(request_url)
1000 0.003 0.000 0.024 0.000 models.py:406(prepare_headers)
1000 0.003 0.000 0.007 0.000 cgi.py:313(parse_header)
999 0.003 0.000 0.003 0.000 __init__.py:76(__delitem__)
3000 0.003 0.000 0.017 0.000 response.py:136(release_conn)
1000 0.003 0.000 0.003 0.000 utils.py:395(unquote_unreserved)
1000 0.003 0.000 0.004 0.000 client.py:1109(<listcomp>)
1000 0.003 0.000 0.009 0.000 models.py:163(register_hook)
1000 0.003 0.000 0.003 0.000 message.py:121(__init__)
1000 0.003 0.000 0.006 0.000 models.py:53(path_url)
2000 0.003 0.000 0.008 0.000 cookies.py:301(update)
1000 0.003 0.000 0.016 0.000 poolmanager.py:101(connection_from_host)
1001 0.002 0.000 0.002 0.000 {method 'settimeout' of '_socket.socket' objects}
6000 0.002 0.000 0.002 0.000 {built-in method getattr}
2000 0.002 0.000 0.046 0.000 client.py:489(read)
1000 0.002 0.000 0.006 0.000 parse.py:903(splitport)
1000 0.002 0.000 0.044 0.000 {function HTTPResponse.read at 0x10ea3c488}
1000 0.002 0.000 0.003 0.000 adapters.py:159(cert_verify)
1000 0.002 0.000 0.020 0.000 structures.py:82(copy)
1000 0.002 0.000 0.013 0.000 utils.py:491(<lambda>)
5000 0.002 0.000 0.003 0.000 utils.py:676(to_native_string)
1000 0.002 0.000 0.039 0.000 models.py:503(prepare_cookies)
1000 0.002 0.000 0.236 0.000 request.py:2423(proxy_bypass_macosx_sysconf)
2000 0.002 0.000 0.011 0.000 connectionpool.py:288(_get_timeout)
5001 0.002 0.000 0.002 0.000 cookiejar.py:1713(__iter__)
1000 0.002 0.000 0.003 0.000 models.py:283(__init__)
1000 0.002 0.000 0.023 0.000 fnmatch.py:19(fnmatch)
1000 0.002 0.000 0.020 0.000 client.py:849(send)
2000 0.002 0.000 0.002 0.000 {method 'format' of 'str' objects}
4000 0.002 0.000 0.002 0.000 {method 'acquire' of '_thread.RLock' objects}
9003 0.002 0.000 0.002 0.000 timeout.py:104(_validate_timeout)
1000 0.002 0.000 0.412 0.000 request.py:2437(proxy_bypass)
1000 0.002 0.000 0.003 0.000 cookiejar.py:1256(_cookie_attrs)
9011 0.002 0.000 0.002 0.000 {method 'append' of 'list' objects}
1000 0.002 0.000 0.007 0.000 parse.py:652(quote)
1000 0.002 0.000 0.011 0.000 client.py:424(_check_close)
2000 0.002 0.000 0.008 0.000 re.py:157(match)
2001 0.002 0.000 0.002 0.000 hooks.py:20(default_hooks)
2010 0.002 0.000 0.003 0.000 threading.py:234(__enter__)
1001 0.002 0.000 0.005 0.000 __init__.py:1509(isEnabledFor)
1000 0.002 0.000 0.003 0.000 parse.py:735(urlencode)
1000 0.002 0.000 0.002 0.000 functools.py:349(__init__)
1000 0.002 0.000 0.097 0.000 client.py:1086(request)
1000 0.002 0.000 0.002 0.000 parse.py:509(unquote)
1000 0.002 0.000 0.012 0.000 utils.py:417(requote_uri)
1000 0.002 0.000 0.721 0.001 utils.py:532(get_environ_proxies)
2010 0.002 0.000 0.002 0.000 threading.py:237(__exit__)
2002 0.002 0.000 0.002 0.000 {method 'split' of 'bytes' objects}
1000 0.002 0.000 0.284 0.000 request.py:2443(getproxies)
1000 0.002 0.000 0.002 0.000 retry.py:192(is_forced_retry)
2000 0.002 0.000 0.005 0.000 <frozen importlib._bootstrap>:2264(_handle_fromlist)
1000 0.002 0.000 0.019 0.000 models.py:481(prepare_auth)
1000 0.002 0.000 0.003 0.000 hooks.py:29(dispatch_hook)
1000 0.002 0.000 0.014 0.000 message.py:452(items)
2001 0.002 0.000 0.009 0.000 cookies.py:436(<listcomp>)
1000 0.002 0.000 0.041 0.000 client.py:520(readinto)
1000 0.002 0.000 0.004 0.000 client.py:459(close)
5002 0.002 0.000 0.002 0.000 {built-in method time}
1000 0.002 0.000 0.005 0.000 models.py:625(is_redirect)
2000 0.002 0.000 0.002 0.000 {method 'extend' of 'list' objects}
1000 0.002 0.000 0.011 0.000 models.py:515(prepare_hooks)
2000 0.002 0.000 0.002 0.000 <string>:12(__new__)
1000 0.002 0.000 0.002 0.000 models.py:642(iter_content)
1000 0.001 0.000 0.007 0.000 sessions.py:92(resolve_redirects)
1000 0.001 0.000 0.002 0.000 client.py:566(_read_and_discard_trailer)
2010 0.001 0.000 0.002 0.000 threading.py:249(_is_owned)
1000 0.001 0.000 0.026 0.000 client.py:1071(endheaders)
999 0.001 0.000 0.001 0.000 {method 'register' of 'select.poll' objects}
2999 0.001 0.000 0.001 0.000 client.py:479(isclosed)
1000 0.001 0.000 0.003 0.000 {function HTTPResponse.close at 0x10ea3c268}
1000 0.001 0.000 0.001 0.000 {method 'sort' of 'list' objects}
1000 0.001 0.000 0.002 0.000 parse.py:166(_userinfo)
2010 0.001 0.000 0.002 0.000 queue.py:242(_qsize)
1000 0.001 0.000 0.014 0.000 connectionpool.py:248(_put_conn)
2000 0.001 0.000 0.002 0.000 posixpath.py:49(normcase)
4000 0.001 0.000 0.001 0.000 {method 'release' of '_thread.RLock' objects}
1000 0.001 0.000 0.002 0.000 timeout.py:169(start_connect)
5000 0.001 0.000 0.001 0.000 {method 'upper' of 'str' objects}
1000 0.001 0.000 0.003 0.000 parse.py:135(username)
8002 0.001 0.000 0.001 0.000 {method 'join' of 'str' objects}
1000 0.001 0.000 0.001 0.000 socket.py:238(_decref_socketios)
1000 0.001 0.000 0.001 0.000 {method 'update' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 {built-in method fromkeys}
1000 0.001 0.000 0.113 0.000 request.py:2427(getproxies_macosx_sysconf)
1000 0.001 0.000 0.001 0.000 response.py:318(closed)
1000 0.001 0.000 0.006 0.000 __init__.py:1252(debug)
2000 0.001 0.000 0.001 0.000 cookies.py:100(__init__)
2000 0.001 0.000 0.001 0.000 {method 'find' of 'bytes' objects}
5000 0.001 0.000 0.001 0.000 {method 'setdefault' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 {method 'read' of '_io.BufferedReader' objects}
1000 0.001 0.000 0.001 0.000 sessions.py:75(merge_hooks)
2010 0.001 0.000 0.001 0.000 {method 'acquire' of '_thread.lock' objects}
1000 0.001 0.000 0.002 0.000 client.py:469(flush)
3006 0.001 0.000 0.001 0.000 {built-in method proxy}
2010 0.001 0.000 0.001 0.000 {method '__enter__' of '_thread.lock' objects}
1000 0.001 0.000 0.002 0.000 models.py:469(prepare_content_length)
1000 0.001 0.000 0.001 0.000 utils.py:50(super_len)
6001 0.001 0.000 0.001 0.000 {method 'keys' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 cookiejar.py:1249(_cookies_for_request)
1000 0.001 0.000 0.001 0.000 models.py:328(prepare_method)
5000 0.001 0.000 0.001 0.000 {method 'values' of 'dict' objects}
1000 0.001 0.000 0.010 0.000 client.py:454(_close_conn)
4000 0.001 0.000 0.001 0.000 cookies.py:107(info)
2000 0.001 0.000 0.001 0.000 posixpath.py:38(_get_sep)
1000 0.001 0.000 0.001 0.000 {method '_checkClosed' of '_io._IOBase' objects}
1000 0.001 0.000 0.007 0.000 sessions.py:602(<listcomp>)
2000 0.001 0.000 0.001 0.000 functools.py:377(<genexpr>)
1000 0.001 0.000 0.001 0.000 {method 'rstrip' of 'bytes' objects}
3000 0.001 0.000 0.001 0.000 cookiejar.py:46(_debug)
1000 0.001 0.000 0.001 0.000 queue.py:248(_get)
1000 0.001 0.000 0.001 0.000 {built-in method min}
2000 0.001 0.000 0.001 0.000 {method 'rstrip' of 'str' objects}
1000 0.001 0.000 0.001 0.000 timeout.py:12(current_time)
2001 0.001 0.000 0.001 0.000 timeout.py:193(connect_timeout)
2010 0.001 0.000 0.001 0.000 {method '__exit__' of '_thread.lock' objects}
1000 0.001 0.000 0.001 0.000 {method 'groups' of '_sre.SRE_Match' objects}
1000 0.001 0.000 0.002 0.000 {method '_checkReadable' of '_io._IOBase' objects}
2006 0.001 0.000 0.001 0.000 {method 'pop' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 models.py:836(close)
1000 0.001 0.000 0.009 0.000 parse.py:250(geturl)
1000 0.001 0.000 0.001 0.000 timeout.py:211(read_timeout)
2001 0.001 0.000 0.001 0.000 {method 'strip' of 'str' objects}
1010 0.001 0.000 0.001 0.000 queue.py:245(_put)
1000 0.001 0.000 0.001 0.000 structures.py:62(__len__)
2000 0.001 0.000 0.001 0.000 {method 'isdigit' of 'str' objects}
2000 0.001 0.000 0.001 0.000 {method 'group' of '_sre.SRE_Match' objects}
1000 0.001 0.000 0.002 0.000 _collections_abc.py:459(__len__)
1000 0.001 0.000 0.001 0.000 {method 'readinto' of '_io.BufferedReader' objects}
1000 0.001 0.000 0.001 0.000 {function HTTPResponse.flush at 0x10ea3c2f0}
999 0.000 0.000 0.000 0.000 {built-in method poll}
1000 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects}
1000 0.000 0.000 0.000 0.000 {built-in method hash}
1000 0.000 0.000 0.000 0.000 utils.py:346(iter_slices)
1000 0.000 0.000 0.000 0.000 functools.py:353(__hash__)
1000 0.000 0.000 0.000 0.000 models.py:172(<genexpr>)
1000 0.000 0.000 0.000 0.000 {built-in method all}
1000 0.000 0.000 0.000 0.000 {method 'pop' of 'list' objects}
1000 0.000 0.000 0.000 0.000 cookies.py:77(get_new_headers)
1000 0.000 0.000 0.000 0.000 {built-in method any}
1000 0.000 0.000 0.000 0.000 connectionpool.py:278(_validate_conn)
1000 0.000 0.000 0.000 0.000 adapters.py:287(add_headers)
2.160902976989746
2188027 function calls (2184884 primitive calls) in 2.161 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1000 0.147 0.000 0.147 0.000 {built-in method _get_proxy_settings}
1000 0.106 0.000 0.106 0.000 {built-in method _get_proxies}
92000 0.074 0.000 0.314 0.000 _collections_abc.py:496(__iter__)
78000 0.070 0.000 0.184 0.000 os.py:628(__getitem__)
195134 0.052 0.000 0.105 0.000 {built-in method isinstance}
2000 0.047 0.000 0.335 0.000 request.py:2321(getproxies_environment)
78000 0.043 0.000 0.074 0.000 os.py:704(encode)
11005 0.042 0.000 0.107 0.000 _collections_abc.py:575(update)
144000 0.040 0.000 0.077 0.000 os.py:708(decode)
148000 0.039 0.000 0.039 0.000 {method 'decode' of 'bytes' objects}
1000 0.037 0.000 0.037 0.000 {method 'recv_into' of '_socket.socket' objects}
27001 0.033 0.000 0.053 0.000 abc.py:178(__instancecheck__)
108003/107003 0.032 0.000 0.039 0.000 {method 'encode' of 'str' objects}
72000 0.029 0.000 0.066 0.000 os.py:651(__iter__)
7000 0.028 0.000 0.169 0.000 sessions.py:42(merge_setting)
198005 0.025 0.000 0.025 0.000 {method 'lower' of 'str' objects}
8000 0.024 0.000 0.069 0.000 parse.py:286(urlparse)
21000 0.022 0.000 0.025 0.000 parse.py:98(_coerce_args)
35040 0.021 0.000 0.021 0.000 {built-in method hasattr}
1000 0.020 0.000 0.031 0.000 socket.py:196(makefile)
38099 0.020 0.000 0.020 0.000 _weakrefset.py:70(__contains__)
1000 0.018 0.000 0.949 0.001 sessions.py:538(send)
1000 0.017 0.000 0.435 0.000 connectionpool.py:317(_make_request)
7000 0.017 0.000 0.047 0.000 utils.py:147(to_key_val_list)
1000 0.016 0.000 0.016 0.000 {method 'sendall' of '_socket.socket' objects}
10000 0.016 0.000 0.059 0.000 {method 'readline' of '_io.BufferedReader' objects}
9000 0.016 0.000 0.029 0.000 parse.py:319(urlsplit)
5000 0.016 0.000 0.024 0.000 client.py:1051(putheader)
2004 0.016 0.000 0.030 0.000 __init__.py:41(__init__)
9000 0.016 0.000 0.037 0.000 message.py:463(get)
8000 0.015 0.000 0.045 0.000 _collections_abc.py:419(get)
2000 0.015 0.000 0.102 0.000 feedparser.py:217(_parsegen)
1000 0.015 0.000 0.083 0.000 request.py:2360(_proxy_bypass_macosx_sysconf)
1000 0.014 0.000 0.034 0.000 feedparser.py:470(_parse_headers)
1000 0.014 0.000 0.558 0.001 connectionpool.py:421(urlopen)
1000 0.013 0.000 0.173 0.000 client.py:249(parse_headers)
1000 0.013 0.000 0.768 0.001 adapters.py:323(send)
2000 0.013 0.000 0.030 0.000 url.py:119(parse_url)
1000 0.013 0.000 2.142 0.002 sessions.py:385(request)
1000 0.012 0.000 0.396 0.000 sessions.py:345(prepare_request)
2033 0.012 0.000 0.012 0.000 {built-in method stat}
5001 0.012 0.000 0.085 0.000 structures.py:42(__init__)
1 0.012 0.012 2.167 2.167 bench.py:15(run)
11001 0.011 0.000 0.011 0.000 {method 'match' of '_sre.SRE_Pattern' objects}
1000 0.011 0.000 0.093 0.000 client.py:1107(_send_request)
2000 0.011 0.000 0.085 0.000 response.py:160(read)
2000 0.011 0.000 0.028 0.000 cookiejar.py:1638(extract_cookies)
2000 0.010 0.000 0.031 0.000 posixpath.py:221(expanduser)
1000 0.010 0.000 0.264 0.000 client.py:344(begin)
2000 0.010 0.000 0.011 0.000 request.py:2376(ip2num)
1000 0.010 0.000 0.016 0.000 {built-in method gethostbyname}
16001 0.010 0.000 0.010 0.000 {method 'split' of 'str' objects}
1000 0.010 0.000 0.062 0.000 utils.py:70(get_netrc_auth)
1000 0.010 0.000 0.021 0.000 client.py:928(putrequest)
1000 0.009 0.000 0.038 0.000 client.py:605(_readinto_chunked)
13000 0.009 0.000 0.019 0.000 _policybase.py:269(_sanitize_header)
1000 0.009 0.000 0.070 0.000 models.py:334(prepare_url)
1000 0.009 0.000 0.033 0.000 models.py:539(__init__)
1000 0.009 0.000 0.777 0.001 sessions.py:617(merge_environment_settings)
17004 0.009 0.000 0.011 0.000 structures.py:48(__setitem__)
14000 0.009 0.000 0.010 0.000 structures.py:53(__getitem__)
1000 0.008 0.000 0.109 0.000 adapters.py:196(build_response)
2002 0.008 0.000 0.012 0.000 idna.py:147(encode)
5000 0.008 0.000 0.014 0.000 _policybase.py:281(header_source_parse)
1000 0.008 0.000 0.060 0.000 client.py:312(_read_status)
3001 0.008 0.000 0.016 0.000 cookiejar.py:1220(__init__)
7000 0.008 0.000 0.009 0.000 _collections.py:154(__getitem__)
22021 0.008 0.000 0.008 0.000 {method 'get' of 'dict' objects}
59337/58328 0.008 0.000 0.008 0.000 {built-in method len}
1000 0.008 0.000 0.049 0.000 response.py:278(from_httplib)
999 0.007 0.000 0.007 0.000 {method 'poll' of 'select.poll' objects}
4000 0.007 0.000 0.033 0.000 message.py:565(get_content_type)
1000 0.007 0.000 0.010 0.000 feedparser.py:139(__init__)
1000 0.007 0.000 0.007 0.000 socket.py:348(__init__)
1000 0.007 0.000 0.020 0.000 cookiejar.py:1315(add_cookie_header)
2000 0.007 0.000 0.017 0.000 _collections.py:49(__getitem__)
4000 0.007 0.000 0.009 0.000 message.py:498(get_all)
8000 0.006 0.000 0.010 0.000 _collections_abc.py:438(items)
5001 0.006 0.000 0.011 0.000 cookiejar.py:1181(vals_sorted_by_key)
1000 0.006 0.000 0.037 0.000 client.py:282(__init__)
2000 0.006 0.000 0.006 0.000 {built-in method utcnow}
3001 0.006 0.000 0.008 0.000 timeout.py:94(__init__)
2000 0.006 0.000 0.058 0.000 cookies.py:114(extract_cookies_to_jar)
2001 0.006 0.000 0.029 0.000 cookies.py:424(cookiejar_from_dict)
4000 0.006 0.000 0.021 0.000 _collections_abc.py:426(__contains__)
2000 0.006 0.000 0.008 0.000 url.py:86(split_first)
3000 0.006 0.000 0.034 0.000 cookies.py:33(__init__)
1000 0.006 0.000 0.064 0.000 adapters.py:232(get_connection)
15004 0.006 0.000 0.006 0.000 {method 'find' of 'str' objects}
3001 0.005 0.000 0.005 0.000 cookiejar.py:854(__init__)
14001 0.005 0.000 0.005 0.000 {method 'startswith' of 'str' objects}
1000 0.005 0.000 0.018 0.000 _collections.py:230(extend)
1000 0.005 0.000 0.306 0.000 client.py:1128(getresponse)
13000 0.005 0.000 0.024 0.000 _policybase.py:299(header_fetch_parse)
1010 0.005 0.000 0.013 0.000 queue.py:118(put)
1000 0.005 0.000 0.174 0.000 models.py:298(prepare)
1000 0.005 0.000 0.146 0.000 parser.py:42(parse)
26242 0.005 0.000 0.005 0.000 {method 'append' of 'list' objects}
2010 0.005 0.000 0.007 0.000 threading.py:329(notify)
2000 0.005 0.000 0.008 0.000 parse.py:386(urlunsplit)
8000 0.005 0.000 0.011 0.000 feedparser.py:128(__next__)
13000 0.005 0.000 0.008 0.000 utils.py:51(_has_surrogates)
8000 0.005 0.000 0.006 0.000 feedparser.py:74(readline)
20000 0.005 0.000 0.005 0.000 structures.py:60(<genexpr>)
1000 0.005 0.000 0.007 0.000 functools.py:356(_make_key)
1000 0.005 0.000 0.014 0.000 functools.py:455(wrapper)
2000 0.005 0.000 0.008 0.000 client.py:550(_read_next_chunk_size)
2000 0.005 0.000 0.007 0.000 __init__.py:176(pop)
1000 0.004 0.000 2.147 0.002 sessions.py:468(get)
1000 0.004 0.000 0.006 0.000 models.py:210(__init__)
1000 0.004 0.000 0.005 0.000 response.py:91(__init__)
4000 0.004 0.000 0.006 0.000 message.py:30(_splitparam)
1000 0.004 0.000 0.012 0.000 queue.py:150(get)
2000 0.004 0.000 0.103 0.000 models.py:719(content)
2000 0.004 0.000 0.014 0.000 cookiejar.py:1558(make_cookies)
9000/8000 0.004 0.000 0.099 0.000 {method 'join' of 'bytes' objects}
1000 0.004 0.000 0.005 0.000 socket.py:439(close)
2000 0.004 0.000 0.004 0.000 socket.py:401(readable)
1000 0.004 0.000 0.017 0.000 utils.py:663(get_auth_from_url)
5000 0.004 0.000 0.005 0.000 _collections.py:207(add)
2000 0.004 0.000 0.017 0.000 parse.py:375(urlunparse)
7000 0.004 0.000 0.016 0.000 sessions.py:70(<genexpr>)
1000 0.004 0.000 0.008 0.000 models.py:414(prepare_body)
5002 0.004 0.000 0.004 0.000 {built-in method sorted}
1000 0.004 0.000 0.011 0.000 sessions.py:641(get_adapter)
1000 0.004 0.000 0.029 0.000 connectionpool.py:210(_get_conn)
4000 0.004 0.000 0.004 0.000 structures.py:59(__iter__)
10003 0.004 0.000 0.004 0.000 {built-in method __new__ of type object at 0x10e356a20}
2000 0.004 0.000 0.092 0.000 response.py:256(stream)
5001 0.004 0.000 0.014 0.000 cookiejar.py:1185(deepvalues)
1000 0.004 0.000 0.009 0.000 {method 'close' of '_io.BufferedReader' objects}
2000 0.004 0.000 0.012 0.000 cookies.py:444(merge_cookies)
1 0.004 0.004 0.004 0.004 {method 'read' of '_io.TextIOWrapper' objects}
2004 0.003 0.000 0.005 0.000 re.py:277(_compile)
2000 0.003 0.000 0.106 0.000 feedparser.py:180(_call_parse)
2000 0.003 0.000 0.004 0.000 cgi.py:301(_parseparam)
2000 0.003 0.000 0.015 0.000 genericpath.py:16(exists)
8000 0.003 0.000 0.003 0.000 _collections_abc.py:456(__init__)
2000 0.003 0.000 0.008 0.000 timeout.py:154(clone)
2000 0.003 0.000 0.006 0.000 url.py:16(__new__)
1000 0.003 0.000 0.150 0.000 parser.py:60(parsestr)
3000 0.003 0.000 0.003 0.000 response.py:1(is_fp_closed)
1000 0.003 0.000 0.024 0.000 client.py:904(_send_output)
24010 0.003 0.000 0.003 0.000 {method 'items' of 'dict' objects}
1000 0.003 0.000 0.021 0.000 _collections.py:141(__init__)
5005 0.003 0.000 0.003 0.000 __init__.py:87(__iter__)
1000 0.003 0.000 0.012 0.000 models.py:74(_encode_params)
1000 0.003 0.000 0.004 0.000 client.py:669(_safe_readinto)
1000 0.003 0.000 0.007 0.000 feedparser.py:97(push)
1000 0.003 0.000 0.011 0.000 message.py:460(<listcomp>)
2000 0.003 0.000 0.003 0.000 message.py:121(__init__)
999 0.003 0.000 0.013 0.000 connection.py:12(is_connection_dropped)
21000 0.003 0.000 0.003 0.000 parse.py:87(_noop)
3004 0.003 0.000 0.003 0.000 threading.py:75(RLock)
1000 0.003 0.000 0.035 0.000 cookies.py:131(get_cookie_header)
1000 0.003 0.000 0.005 0.000 feedparser.py:199(_new_message)
1000 0.003 0.000 0.018 0.000 fnmatch.py:64(fnmatchcase)
3000 0.003 0.000 0.025 0.000 message.py:589(get_content_maintype)
5000 0.003 0.000 0.005 0.000 models.py:410(<genexpr>)
1002 0.003 0.000 0.003 0.000 __init__.py:62(__setitem__)
1000 0.003 0.000 0.042 0.000 socket.py:360(readinto)
1000 0.003 0.000 0.005 0.000 client.py:646(_safe_read)
1000 0.003 0.000 0.004 0.000 parse.py:713(quote_from_bytes)
1000 0.003 0.000 0.032 0.000 poolmanager.py:129(connection_from_url)
1000 0.003 0.000 0.007 0.000 cookiejar.py:1694(clear_expired_cookies)
1000 0.003 0.000 0.016 0.000 adapters.py:263(request_url)
6000 0.003 0.000 0.004 0.000 client.py:897(_output)
2000 0.003 0.000 0.095 0.000 models.py:652(generate)
1000 0.003 0.000 0.011 0.000 utils.py:308(get_encoding_from_headers)
1000 0.003 0.000 0.004 0.000 client.py:1109(<listcomp>)
1000 0.003 0.000 0.009 0.000 models.py:163(register_hook)
1001 0.003 0.000 0.003 0.000 __init__.py:1495(getEffectiveLevel)
1001 0.003 0.000 0.003 0.000 {method 'settimeout' of '_socket.socket' objects}
2000 0.003 0.000 0.003 0.000 feedparser.py:121(pushlines)
1000 0.003 0.000 0.023 0.000 models.py:406(prepare_headers)
1000 0.003 0.000 0.426 0.000 utils.py:487(should_bypass_proxies)
6075 0.002 0.000 0.002 0.000 {built-in method getattr}
1000 0.002 0.000 0.005 0.000 models.py:53(path_url)
1000 0.002 0.000 0.003 0.000 utils.py:395(unquote_unreserved)
3000 0.002 0.000 0.016 0.000 response.py:136(release_conn)
1000 0.002 0.000 0.015 0.000 poolmanager.py:101(connection_from_host)
1000 0.002 0.000 0.020 0.000 structures.py:82(copy)
2000 0.002 0.000 0.010 0.000 connectionpool.py:288(_get_timeout)
999 0.002 0.000 0.003 0.000 __init__.py:76(__delitem__)
2000 0.002 0.000 0.007 0.000 cookies.py:301(update)
1000 0.002 0.000 0.007 0.000 cgi.py:313(parse_header)
1000 0.002 0.000 0.042 0.000 {function HTTPResponse.read at 0x10ea3c488}
5000 0.002 0.000 0.003 0.000 utils.py:676(to_native_string)
1000 0.002 0.000 0.003 0.000 adapters.py:159(cert_verify)
1000 0.002 0.000 0.012 0.000 utils.py:491(<lambda>)
1000 0.002 0.000 0.023 0.000 feedparser.py:186(close)
1000 0.002 0.000 0.037 0.000 models.py:503(prepare_cookies)
2114 0.002 0.000 0.002 0.000 {method 'format' of 'str' objects}
1000 0.002 0.000 0.003 0.000 models.py:283(__init__)
2000 0.002 0.000 0.044 0.000 client.py:489(read)
1000 0.002 0.000 0.022 0.000 fnmatch.py:19(fnmatch)
1000 0.002 0.000 0.020 0.000 client.py:849(send)
1000 0.002 0.000 0.006 0.000 parse.py:903(splitport)
5001 0.002 0.000 0.002 0.000 cookiejar.py:1713(__iter__)
7252 0.002 0.000 0.002 0.000 {method 'rstrip' of 'str' objects}
2000 0.002 0.000 0.002 0.000 {method 'splitlines' of 'str' objects}
8000 0.002 0.000 0.002 0.000 {method 'pop' of 'list' objects}
5000 0.002 0.000 0.003 0.000 message.py:480(set_raw)
1000 0.002 0.000 0.232 0.000 request.py:2423(proxy_bypass_macosx_sysconf)
9003 0.002 0.000 0.002 0.000 timeout.py:104(_validate_timeout)
4000 0.002 0.000 0.002 0.000 {method 'acquire' of '_thread.RLock' objects}
15139 0.002 0.000 0.002 0.000 {method 'join' of 'str' objects}
1000 0.002 0.000 0.003 0.000 cookiejar.py:1256(_cookie_attrs)
1000 0.002 0.000 0.404 0.000 request.py:2437(proxy_bypass)
1000 0.002 0.000 0.095 0.000 client.py:1086(request)
2000 0.002 0.000 0.008 0.000 re.py:157(match)
1000 0.002 0.000 0.007 0.000 parse.py:652(quote)
1000 0.002 0.000 0.010 0.000 client.py:424(_check_close)
2001 0.002 0.000 0.002 0.000 hooks.py:20(default_hooks)
1000 0.002 0.000 0.002 0.000 parse.py:509(unquote)
1000 0.002 0.000 0.003 0.000 parse.py:735(urlencode)
1000 0.002 0.000 0.002 0.000 functools.py:349(__init__)
1001 0.002 0.000 0.004 0.000 __init__.py:1509(isEnabledFor)
1000 0.002 0.000 0.702 0.001 utils.py:532(get_environ_proxies)
2010 0.002 0.000 0.003 0.000 threading.py:234(__enter__)
2010 0.002 0.000 0.002 0.000 threading.py:237(__exit__)
1000 0.002 0.000 0.003 0.000 feedparser.py:68(close)
1000 0.002 0.000 0.107 0.000 feedparser.py:175(feed)
1000 0.002 0.000 0.011 0.000 utils.py:417(requote_uri)
1000 0.002 0.000 0.002 0.000 retry.py:192(is_forced_retry)
2002 0.002 0.000 0.002 0.000 {method 'split' of 'bytes' objects}
1000 0.002 0.000 0.019 0.000 models.py:481(prepare_auth)
1000 0.002 0.000 0.274 0.000 request.py:2443(getproxies)
2005 0.002 0.000 0.005 0.000 <frozen importlib._bootstrap>:2264(_handle_fromlist)
1000 0.002 0.000 0.040 0.000 client.py:520(readinto)
5000 0.002 0.000 0.002 0.000 {method 'lstrip' of 'str' objects}
1000 0.002 0.000 0.003 0.000 hooks.py:29(dispatch_hook)
1000 0.002 0.000 0.011 0.000 models.py:515(prepare_hooks)
5002 0.002 0.000 0.002 0.000 {built-in method time}
2004 0.001 0.000 0.002 0.000 {method 'extend' of 'list' objects}
1000 0.001 0.000 0.005 0.000 models.py:625(is_redirect)
2001 0.001 0.000 0.009 0.000 cookies.py:436(<listcomp>)
1000 0.001 0.000 0.004 0.000 client.py:459(close)
1000 0.001 0.000 0.012 0.000 message.py:452(items)
1000 0.001 0.000 0.001 0.000 models.py:642(iter_content)
1000 0.001 0.000 0.006 0.000 sessions.py:92(resolve_redirects)
1000 0.001 0.000 0.002 0.000 client.py:566(_read_and_discard_trailer)
2000 0.001 0.000 0.002 0.000 posixpath.py:49(normcase)
999 0.001 0.000 0.001 0.000 {method 'register' of 'select.poll' objects}
6002 0.001 0.000 0.001 0.000 {method 'strip' of 'str' objects}
4000 0.001 0.000 0.001 0.000 {method 'count' of 'str' objects}
2010 0.001 0.000 0.001 0.000 queue.py:242(_qsize)
1000 0.001 0.000 0.014 0.000 connectionpool.py:248(_put_conn)
1000 0.001 0.000 0.002 0.000 parse.py:166(_userinfo)
2010 0.001 0.000 0.002 0.000 threading.py:249(_is_owned)
4000 0.001 0.000 0.001 0.000 {method 'release' of '_thread.RLock' objects}
2999 0.001 0.000 0.001 0.000 client.py:479(isclosed)
1000 0.001 0.000 0.003 0.000 parse.py:135(username)
1000 0.001 0.000 0.001 0.000 {method 'sort' of 'list' objects}
1000 0.001 0.000 0.002 0.000 timeout.py:169(start_connect)
1000 0.001 0.000 0.003 0.000 {function HTTPResponse.close at 0x10ea3c268}
1000 0.001 0.000 0.025 0.000 client.py:1071(endheaders)
5000 0.001 0.000 0.001 0.000 {method 'upper' of 'str' objects}
2000 0.001 0.000 0.001 0.000 {method 'read' of '_io.StringIO' objects}
1000 0.001 0.000 0.001 0.000 response.py:318(closed)
1000 0.001 0.000 0.001 0.000 {built-in method fromkeys}
2000 0.001 0.000 0.001 0.000 cookies.py:100(__init__)
1000 0.001 0.000 0.001 0.000 {method 'update' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 socket.py:238(_decref_socketios)
1000 0.001 0.000 0.001 0.000 {method 'read' of '_io.BufferedReader' objects}
1000 0.001 0.000 0.001 0.000 {method '_checkClosed' of '_io._IOBase' objects}
1000 0.001 0.000 0.005 0.000 __init__.py:1252(debug)
5000 0.001 0.000 0.001 0.000 {method 'setdefault' of 'dict' objects}
1000 0.001 0.000 0.107 0.000 request.py:2427(getproxies_macosx_sysconf)
2010 0.001 0.000 0.001 0.000 {method 'acquire' of '_thread.lock' objects}
2000 0.001 0.000 0.001 0.000 {method 'find' of 'bytes' objects}
1000 0.001 0.000 0.001 0.000 utils.py:50(super_len)
2010 0.001 0.000 0.001 0.000 {method '__enter__' of '_thread.lock' objects}
1000 0.001 0.000 0.001 0.000 sessions.py:75(merge_hooks)
1000 0.001 0.000 0.001 0.000 feedparser.py:52(__init__)
1000 0.001 0.000 0.001 0.000 cookiejar.py:1249(_cookies_for_request)
1000 0.001 0.000 0.002 0.000 models.py:469(prepare_content_length)
1000 0.001 0.000 0.001 0.000 client.py:469(flush)
4000 0.001 0.000 0.001 0.000 {method 'partition' of 'str' objects}
3006 0.001 0.000 0.001 0.000 {built-in method proxy}
2001 0.001 0.000 0.001 0.000 posixpath.py:38(_get_sep)
1000 0.001 0.000 0.001 0.000 models.py:328(prepare_method)
6001 0.001 0.000 0.001 0.000 {method 'keys' of 'dict' objects}
5000 0.001 0.000 0.001 0.000 {method 'values' of 'dict' objects}
1000 0.001 0.000 0.001 0.000 feedparser.py:209(_pop_message)
4000 0.001 0.000 0.001 0.000 cookies.py:107(info)
1000 0.001 0.000 0.010 0.000 client.py:454(_close_conn)
2004 0.001 0.000 0.001 0.000 {method 'endswith' of 'str' objects}
1000 0.001 0.000 0.001 0.000 message.py:304(set_payload)
1000 0.001 0.000 0.007 0.000 sessions.py:602(<listcomp>)
1037 0.001 0.000 0.001 0.000 {built-in method min}
2000 0.001 0.000 0.001 0.000 functools.py:377(<genexpr>)
3000 0.001 0.000 0.001 0.000 cookiejar.py:46(_debug)
1000 0.001 0.000 0.002 0.000 {method '_checkReadable' of '_io._IOBase' objects}
1000 0.001 0.000 0.001 0.000 queue.py:248(_get)
2006 0.001 0.000 0.001 0.000 {method 'pop' of 'dict' objects}
2001 0.001 0.000 0.001 0.000 timeout.py:193(connect_timeout)
1001 0.001 0.000 0.001 0.000 {method 'rstrip' of 'bytes' objects}
1000 0.001 0.000 0.001 0.000 timeout.py:12(current_time)
1000 0.001 0.000 0.001 0.000 models.py:836(close)
2010 0.001 0.000 0.001 0.000 {method '__exit__' of '_thread.lock' objects}
1001 0.001 0.000 0.001 0.000 {method 'groups' of '_sre.SRE_Match' objects}
4 0.001 0.000 0.001 0.000 {built-in method loads}
1000 0.001 0.000 0.001 0.000 timeout.py:211(read_timeout)
1000 0.001 0.000 0.009 0.000 parse.py:250(geturl)
1000 0.001 0.000 0.001 0.000 parser.py:18(__init__)
1000 0.001 0.000 0.001 0.000 feedparser.py:148(<lambda>)
2000 0.001 0.000 0.001 0.000 {method 'isdigit' of 'str' objects}
2000 0.001 0.000 0.001 0.000 {method 'group' of '_sre.SRE_Match' objects}
1000 0.001 0.000 0.002 0.000 _collections_abc.py:459(__len__)
1000 0.001 0.000 0.001 0.000 {method 'readinto' of '_io.BufferedReader' objects}
999 0.001 0.000 0.001 0.000 {built-in method poll}
8 0.001 0.000 0.001 0.000 sre_compile.py:255(_optimize_charset)
1000 0.001 0.000 0.001 0.000 structures.py:62(__len__)
1000 0.001 0.000 0.001 0.000 {function HTTPResponse.flush at 0x10ea3c2f0}
1 0.001 0.001 0.001 0.001 {built-in method fork_exec}
@Lukasa
Copy link

Lukasa commented Mar 18, 2015

To enable keep-alive, change your run function to this:

def run():
    s = requests.Session()
    t0 = time.time()
    for _ in range(1000):
        resp = s.get('http://127.0.0.1:8080/', stream=False)
        assert resp.content == b'Hello, World!\n'
    t1 = time.time()
    print(t1-t0)

There's no need to call 'close' on the response, requests does that automatically when you consume the content. Session objects are what we use to hang our persistent connections from, so you need one of those.

Why are you setting stream to False?

@methane
Copy link
Author

methane commented Mar 18, 2015

@Lukasa Thanks.

http://docs.python-requests.org/en/latest/user/advanced/#keep-alive says:

Note that connections are only released back to the pool for reuse once all body data has been read; be sure to either set stream to False or read the content property of the Response object.

@methane
Copy link
Author

methane commented Mar 18, 2015

As far as profile, bottleneck is finding proxy...

@Lukasa
Copy link

Lukasa commented Mar 18, 2015

You're reading the content property, so there's no need to set stream=False. Shouldn't affect performance too much though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment