Advertisement
dereksir

Untitled

Jan 9th, 2024
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import urllib3
  2. import time
  3.  
  4. # create a PoolManager instance
  5. http = urllib3.PoolManager()
  6.  
  7. start_time = time.time()  # record the start time
  8. response = http.request('GET', 'https://httpbin.org') # make the get request
  9. end_time = time.time()    # record the end time
  10.  
  11. # calculate the time taken
  12. elapsed_time = end_time - start_time
  13.  
  14. # Optionally, do something with the response and the time taken
  15. # print(f"Response: {response.data}")
  16. print(f"Time taken: {elapsed_time} seconds")
  17.  
  18.  
  19.  
  20. #.. Time taken: 1.02 seconds
  21.  
  22.  
  23. ###..... Requests Test .....###
  24.  
  25. import requests
  26. import time
  27.  
  28. start_time = time.time()  # record the start time
  29. response = requests.get('https://httpbin.org') # make GET request
  30. end_time = time.time()    # record the end time
  31.  
  32. # calculate the time taken
  33. elapsed_time = end_time - start_time
  34.  
  35. # optionally, do something with the response and the time taken
  36. # print(f"Response: {response.data}")
  37. print(f"Time taken: {elapsed_time} seconds")
  38.  
  39.  
  40. #... Time taken: 1.07.. seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement