Created
March 2, 2015 22:53
-
-
Save zsalzbank/90ebcaaf94f6c34e9559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import requests | |
| headers = {} | |
| url = 'https://sleepy-reaches-6892.herokuapp.com/test' | |
| def test(timeout) : | |
| start = time.time() | |
| response = requests.get(url=url, | |
| timeout=timeout, stream=True, headers=headers) | |
| for x in response.iter_content(2) : | |
| pass | |
| print("T={}, stream iter took: {}".format(timeout, time.time() - start)) | |
| start = time.time() | |
| response = requests.get(url=url, | |
| timeout=timeout, stream=True) | |
| response.content | |
| print("T={}, stream all took: {}".format(timeout, time.time() - start)) | |
| start = time.time() | |
| response = requests.get(url=url, | |
| timeout=timeout, headers=headers) | |
| response.content | |
| print("T={}, no stream took: {}".format(timeout, time.time() - start)) | |
| test(10) | |
| test(None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment