I created a chatbot using dialogflow, and I would like to check how long it takes to process the query sent by the user. How long does NLP take to process the question? Is it even possible to check this?
Upon checking documentation of Dialogflow API, I cannot seem to find any class that can be used to check the processing time.
As a workaround, you can get the current timestamp before the line of code for the REQUEST
and then get the current timestamp after the line of code for the REQUEST
.
Now you may subtract the 2 timestamps and get the processing time.
Please see below sample using python for your reference:
# Create a client
--code here--
# Initialize request argument(s)
--code here--
# Make the request
import time
#ts1 stores the time in seconds before processing the request
ts1 = time.time()
response = client.detect_intent(request=request) #-->line of code for the request
#ts2 stores the time in seconds after processing the request
ts2 = time.time()
print(f"REQUEST_TIME: {ts2-ts1}")
# Handle the response
print(response)