useful snippets
General Info
Useful Snippets

14.0.9 Calculate how much time it takes to do something

Example:

from datetime import datetime

# take the time before the data processing starts
start_time = datetime.now()
start_time_datetime = start_time.strftime("%m/%d/%Y %H:%M:%S")

##############################
# the thing you want to time #
##############################

# take the time after the processing
end_time          = datetime.now()
end_time_datetime = end_time.strftime("%m/%d/%Y %H:%M:%S")


# get the total runtime (before and after the data processing)
runtime = end_time - start_time 
runtime_seconds = runtime.seconds