Reputation: 8778
So I want know the response time of my Flask web app. My first idea was to use the time
module of Python. Using the tutorial example, it would look like this:
import time
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
t0 = time.clock()
res = f() # prepare response
t1 = time.clock()
nsec = t0-t1 # response time
return res
But this approach only measures the response time of the GET handler. While this is informative, this is not a measure of the response time for the client sending the request. For example, if the web app receives more requests than it can handle, the response time for the sender will increase, while t0-t1
will stay constant.
How can I measure the actual response time of my web app?
Upvotes: 3
Views: 1241
Reputation: 308783
Measuring from the client requires that the client send their submit time. When the page loads or document is ready, subtract that time to get the total roundtrip time from the point of view of the client.
Upvotes: 2