0

For a small app that monitors a webserver I need to collect the response time. Here is my code snippet:

    start = time.process_time()
    response = requests.post(url, timeout=3.0)
    request_time = time.process_time() - start
    print("Request completed in: " + str(request_time*1000))
    print(response.elapsed.total_seconds()*100)

The response time is recorded in two different ways (record time before and after request and get difference; response.elapsed.total_seconds()) as I wanted to try both. The output is different. So, which is the correct way to measure the response time?

NazgulNr5
  • 1
  • 1
  • You want to know the elapsed time between making the request and getting the response. How much processor time was used on your machine is quite irrelevant. – Booboo Dec 17 '19 at 15:26
  • Ah, thank you. I forgot that request_time would also include the time that the processor needed. – NazgulNr5 Dec 17 '19 at 16:21

0 Answers0