Categories
python

Python: Check how long a HTTPX Request took to run?

To check the response time of a python httpx request, use the response.elapsed attribute.

import httpx

client = httpx.Client()
response = client.get('https://stoicquotesapi.com/v1/api/quotes/random')

print(response.elapsed.total_seconds())

This will print out the response time:

1.334806

Again:

response.elapsed.total_seconds())